public function ContentModerationStateTest::testExistingContentModerationStateDataRemoval in Drupal 8
Same name and namespace in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testExistingContentModerationStateDataRemoval()
Tests removal of content moderation state entities for preexisting content.
File
- core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php, line 249
Class
- ContentModerationStateTest
- Tests links between a content entity and a content_moderation_state entity.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testExistingContentModerationStateDataRemoval() {
$storage = $this->entityTypeManager
->getStorage('entity_test_mulrevpub');
$entity = $this
->createEntity('entity_test_mulrevpub', 'published', FALSE);
$original_revision_id = $entity
->getRevisionId();
$workflow = $this
->createEditorialWorkflow();
$this
->addEntityTypeAndBundleToWorkflow($workflow, $entity
->getEntityTypeId(), $entity
->bundle());
$entity = $this
->reloadEntity($entity);
$entity->moderation_state = 'draft';
$entity
->save();
$storage
->deleteRevision($entity
->getRevisionId());
$entity = $this
->reloadEntity($entity);
$this
->assertEquals('published', $entity->moderation_state->value);
$this
->assertEquals($original_revision_id, $storage
->getLatestRevisionId($entity
->id()));
}