You are here

public function ContentModerationSyncingTest::testUpdatingPreviousRevisionDuringSync in Drupal 9

Same name and namespace in other branches
  1. 8 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));
}