function ContentModerationSyncingTest::testMultipleRevisionStateChangedDuringSync
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testMultipleRevisionStateChangedDuringSync()
- 8.9.x core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testMultipleRevisionStateChangedDuringSync()
- 11.x 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 91
Class
- ContentModerationSyncingTest
- Test content moderation when an entity is marked as 'syncing'.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testMultipleRevisionStateChangedDuringSync() : void {
$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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.