function ContentModerationStateTest::doTestContentModerationStatePendingRevisionDataRemoval

Same name in other branches
  1. 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::doTestContentModerationStatePendingRevisionDataRemoval()

Tests removal of content moderation state pending entity revisions.

1 call to ContentModerationStateTest::doTestContentModerationStatePendingRevisionDataRemoval()
ContentModerationStateTest::testContentModerationStatePendingRevisionDataRemoval in core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
Tests removal of content moderation state pending entity revisions.

File

core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php, line 287

Class

ContentModerationStateTest
Tests links between a content entity and a content_moderation_state entity.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function doTestContentModerationStatePendingRevisionDataRemoval($entity_type_id) : void {
    $entity = $this->createEntity($entity_type_id, 'published');
    $entity->setNewRevision(TRUE);
    $entity->moderation_state = 'draft';
    $entity->save();
    $content_moderation_state = ContentModerationState::loadFromModeratedEntity($entity);
    $this->assertNotEmpty($content_moderation_state);
    
    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */
    $entity_storage = $this->entityTypeManager
        ->getStorage($entity_type_id);
    $entity_storage->deleteRevision($entity->getRevisionId());
    $content_moderation_state = ContentModerationState::loadFromModeratedEntity($entity);
    $this->assertNull($content_moderation_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.