function ModerationInformationTest::testGetWorkflowForEntity

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

@dataProvider providerWorkflow @covers ::getWorkflowForEntity

File

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

Class

ModerationInformationTest
@coversDefaultClass \Drupal\content_moderation\ModerationInformation[[api-linebreak]] @group content_moderation

Namespace

Drupal\Tests\content_moderation\Unit

Code

public function testGetWorkflowForEntity($workflow) : void {
  $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
  if ($workflow) {
    $workflow_entity = $this->prophesize(WorkflowInterface::class)
      ->reveal();
    $workflow_storage = $this->prophesize(EntityStorageInterface::class);
    $workflow_storage->load('workflow')
      ->willReturn($workflow_entity)
      ->shouldBeCalled();
    $entity_type_manager->getStorage('workflow')
      ->willReturn($workflow_storage->reveal());
  }
  else {
    $workflow_entity = NULL;
  }
  $moderation_information = new ModerationInformation($entity_type_manager->reveal(), $this->setupModerationBundleInfo('test_bundle', $workflow));
  $entity = $this->prophesize(ContentEntityInterface::class);
  $entity->getEntityTypeId()
    ->willReturn('test_entity_type');
  $entity->bundle()
    ->willReturn('test_bundle');
  $this->assertEquals($workflow_entity, $moderation_information->getWorkflowForEntity($entity->reveal()));
}

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