public function ContentModerationSyncingTest::testMultipleRevisionStateChangedDuringSync in Drupal 9
Same name and namespace in other branches
- 8 core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testMultipleRevisionStateChangedDuringSync()
- 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testMultipleRevisionStateChangedDuringSync()
Tests state changes with multiple revisions during a sync.
File
- core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationSyncingTest.php, line 89
Class
- ContentModerationSyncingTest
- Test content moderation when an entity is marked as 'syncing'.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testMultipleRevisionStateChangedDuringSync() {
$entity = EntityTestMulRevPub::create([
'moderation_state' => 'published',
'name' => 'foo',
]);
$entity
->save();
$entity->name = 'bar';
$entity
->save();
$latest_revision_id = $entity
->getRevisionId();
$entity
->setSyncing(TRUE);
$entity->moderation_state = 'draft';
$entity
->save();
$this
->assertEquals($latest_revision_id, $entity
->getRevisionId());
$this
->assertEquals('draft', $entity->moderation_state->value);
$this
->assertEquals('bar', $entity->name->value);
// The default revision will not automatically be assigned to another
// revision, so a draft unpublished revision will be created when syncing
// 'published' to 'draft'.
$this
->assertFalse($entity
->isPublished());
$this
->assertTrue($entity
->isDefaultRevision());
}