function ModerationInformationTest::testIsModeratedEntity

Same name and namespace in other branches
  1. 8.9.x core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php \Drupal\Tests\content_moderation\Unit\ModerationInformationTest::testIsModeratedEntity()
  2. 10 core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php \Drupal\Tests\content_moderation\Unit\ModerationInformationTest::testIsModeratedEntity()
  3. 11.x core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php \Drupal\Tests\content_moderation\Unit\ModerationInformationTest::testIsModeratedEntity()

@dataProvider providerWorkflow @covers ::isModeratedEntity

File

core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php, line 89

Class

ModerationInformationTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21content_moderation%21src%21ModerationInformation.php/class/ModerationInformation/9" title="General service for moderation-related questions about Entity API." class="local">\Drupal\content_moderation\ModerationInformation</a> @group content_moderation

Namespace

Drupal\Tests\content_moderation\Unit

Code

public function testIsModeratedEntity($workflow, $expected) {
    $moderation_information = new ModerationInformation($this->getEntityTypeManager(), $this->setupModerationBundleInfo('test_bundle', $workflow));
    $entity_type = new ContentEntityType([
        'id' => 'test_entity_type',
        'bundle_entity_type' => 'entity_test_bundle',
        'handlers' => [
            'moderation' => ModerationHandler::class,
        ],
    ]);
    $entity = $this->prophesize(ContentEntityInterface::class);
    $entity->getEntityType()
        ->willReturn($entity_type);
    $entity->getEntityTypeId()
        ->willReturn($entity_type->id());
    $entity->bundle()
        ->willReturn('test_bundle');
    $this->assertEquals($expected, $moderation_information->isModeratedEntity($entity->reveal()));
}

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