function ContentModerationStateTest::testExistingContentModerationStateDataRemoval
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testExistingContentModerationStateDataRemoval()
- 8.9.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testExistingContentModerationStateDataRemoval()
- 10 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 307
Class
- ContentModerationStateTest
- Tests links between a content entity and a content_moderation_state entity.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testExistingContentModerationStateDataRemoval() : void {
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
$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()));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.