function ContentModerationSyncingTest::testUpdatingPreviousRevisionDuringSync

Same name in other branches
  1. 8.9.x core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testUpdatingPreviousRevisionDuringSync()
  2. 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testUpdatingPreviousRevisionDuringSync()
  3. 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testUpdatingPreviousRevisionDuringSync()

Tests modifying a previous revision during a sync.

File

core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php, line 117

Class

ContentModerationSyncingTest
Test content moderation when an entity is marked as 'syncing'.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testUpdatingPreviousRevisionDuringSync() {
    $storage = $this->container
        ->get('entity_type.manager')
        ->getStorage('entity_test_mulrevpub');
    $entity = EntityTestMulRevPub::create([
        'moderation_state' => 'published',
        'name' => 'foo',
    ]);
    $entity->save();
    $original_revision_id = $entity->getRevisionId();
    $entity->name = 'bar';
    $entity->save();
    // Sync a change to the 'name' on the original revision ID.
    $original_revision = $storage->loadRevision($original_revision_id);
    $original_revision->setSyncing(TRUE);
    $original_revision->name = 'baz';
    $original_revision->save();
    // The names of each revision should reflect two revisions, the original one
    // having been updated during a sync.
    $this->assertEquals([
        'baz',
        'bar',
    ], $this->getAllRevisionNames($entity));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.