function ContentModerationStateTest::testRevisionDefaultState
Same name in other branches
- 8.9.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testRevisionDefaultState()
- 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testRevisionDefaultState()
- 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testRevisionDefaultState()
Tests the revision default state of the moderation state entity revisions.
@dataProvider basicModerationTestCases
Parameters
string $entity_type_id: The ID of entity type to be tested.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php, line 671
Class
- ContentModerationStateTest
- Tests links between a content entity and a content_moderation_state entity.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testRevisionDefaultState($entity_type_id) {
// Check that the revision default state of the moderated entity and the
// content moderation state entity always match.
$entity = $this->createEntity($entity_type_id, 'published');
$cms_entity = ContentModerationState::loadFromModeratedEntity($entity);
$this->assertEquals($entity->isDefaultRevision(), $cms_entity->isDefaultRevision());
$entity->get('moderation_state')->value = 'published';
$entity->save();
$cms_entity = ContentModerationState::loadFromModeratedEntity($entity);
$this->assertEquals($entity->isDefaultRevision(), $cms_entity->isDefaultRevision());
$entity->get('moderation_state')->value = 'draft';
$entity->save();
$cms_entity = ContentModerationState::loadFromModeratedEntity($entity);
$this->assertEquals($entity->isDefaultRevision(), $cms_entity->isDefaultRevision());
$entity->get('moderation_state')->value = 'published';
$entity->save();
$cms_entity = ContentModerationState::loadFromModeratedEntity($entity);
$this->assertEquals($entity->isDefaultRevision(), $cms_entity->isDefaultRevision());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.