public function ContentModerationStateTest::testRevisionDefaultState in Drupal 9
Same name and namespace in other branches
- 8 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 658
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());
}