function ContentModerationSyncingTest::testSingleRevisionStateChangedDuringSync
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testSingleRevisionStateChangedDuringSync()
- 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testSingleRevisionStateChangedDuringSync()
- 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationSyncingTest::testSingleRevisionStateChangedDuringSync()
Test changing the moderation state during a sync.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationSyncingTest.php, line 63
Class
- ContentModerationSyncingTest
- Test content moderation when an entity is marked as 'syncing'.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testSingleRevisionStateChangedDuringSync() {
$entity = EntityTestMulRevPub::create([
'moderation_state' => 'published',
'name' => 'foo',
]);
$entity->save();
$initial_revision_id = $entity->getRevisionId();
$this->assertTrue($entity->isDefaultRevision());
$this->assertTrue($entity->isPublished());
$entity->setSyncing(TRUE);
$entity->moderation_state = 'draft';
$entity->save();
// If a moderation state is changed to a draft while syncing, it will revert
// to the same properties of an item of content that was initially created
// as a draft.
$this->assertEquals($initial_revision_id, $entity->getRevisionId());
$this->assertFalse($entity->isPublished());
$this->assertTrue($entity->isDefaultRevision());
$this->assertEquals('draft', $entity->moderation_state->value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.