You are here

public function ModerationInformationTest::setupModerationBundleInfo in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php \Drupal\Tests\content_moderation\Unit\ModerationInformationTest::setupModerationBundleInfo()

Sets up content moderation and entity manager mocking.

Parameters

string $bundle: The bundle ID.

string|null $workflow: The workflow ID. If nul no workflow information is added to the bundle.

Return value

\Drupal\Core\Entity\EntityTypeManagerInterface The mocked entity type manager.

4 calls to ModerationInformationTest::setupModerationBundleInfo()
ModerationInformationTest::testGetWorkflowForEntity in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
@dataProvider providerWorkflow @covers ::getWorkflowForEntity
ModerationInformationTest::testIsModeratedEntity in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
@dataProvider providerWorkflow @covers ::isModeratedEntity
ModerationInformationTest::testIsModeratedEntityType in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
@covers ::isModeratedEntityType
ModerationInformationTest::testShouldModerateEntities in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
@dataProvider providerWorkflow @covers ::shouldModerateEntitiesOfBundle

File

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

Class

ModerationInformationTest
@coversDefaultClass \Drupal\content_moderation\ModerationInformation @group content_moderation

Namespace

Drupal\Tests\content_moderation\Unit

Code

public function setupModerationBundleInfo($bundle, $workflow = NULL) {
  $bundle_info_array = [];
  if ($workflow) {
    $bundle_info_array['workflow'] = $workflow;
  }
  $bundle_info = $this
    ->prophesize(EntityTypeBundleInfoInterface::class);
  $bundle_info
    ->getBundleInfo("test_entity_type")
    ->willReturn([
    $bundle => $bundle_info_array,
  ]);
  $bundle_info
    ->getBundleInfo("unmoderated_test_type")
    ->willReturn([
    $bundle => [],
  ]);
  return $bundle_info
    ->reveal();
}