function ContentModerationStateTest::doTestContentModerationStateRevisionDataRemoval
Same name in other branches
- 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::doTestContentModerationStateRevisionDataRemoval()
Tests removal of content moderation state entity revisions.
1 call to ContentModerationStateTest::doTestContentModerationStateRevisionDataRemoval()
- ContentModerationStateTest::testContentModerationStateRevisionDataRemoval in core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php - Tests removal of content moderation state entity revisions.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php, line 245
Class
- ContentModerationStateTest
- Tests links between a content entity and a content_moderation_state entity.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function doTestContentModerationStateRevisionDataRemoval($entity_type_id) : void {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->createEntity($entity_type_id);
$revision_1 = clone $entity;
$this->assertNotNull(ContentModerationState::loadFromModeratedEntity($revision_1));
// Create a second revision.
$entity = $this->reloadEntity($entity);
$entity->setNewRevision(TRUE);
$entity->save();
$revision_2 = clone $entity;
// Create a third revision.
$entity = $this->reloadEntity($entity);
$entity->setNewRevision(TRUE);
$entity->save();
$revision_3 = clone $entity;
// Delete the second revision and check that its content moderation state is
// removed as well, while the content moderation states for revisions 1 and
// 3 are kept in place.
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */
$entity_storage = $this->entityTypeManager
->getStorage($entity_type_id);
$entity_storage->deleteRevision($revision_2->getRevisionId());
$this->assertNotNull(ContentModerationState::loadFromModeratedEntity($revision_1));
$this->assertNull(ContentModerationState::loadFromModeratedEntity($revision_2));
$this->assertNotNull(ContentModerationState::loadFromModeratedEntity($revision_3));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.