function ModerationInformationTest::setupModerationBundleInfo

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()
  2. 8.9.x core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php \Drupal\Tests\content_moderation\Unit\ModerationInformationTest::setupModerationBundleInfo()
  3. 11.x core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php \Drupal\Tests\content_moderation\Unit\ModerationInformationTest::setupModerationBundleInfo()

Sets up content moderation and entity type bundle info 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[[api-linebreak]]
ModerationInformationTest::testIsModeratedEntity in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
@dataProvider providerWorkflow @covers ::isModeratedEntity[[api-linebreak]]
ModerationInformationTest::testIsModeratedEntityType in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
@covers ::isModeratedEntityType[[api-linebreak]]
ModerationInformationTest::testShouldModerateEntities in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
@dataProvider providerWorkflow @covers ::shouldModerateEntitiesOfBundle[[api-linebreak]]

File

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

Class

ModerationInformationTest
@coversDefaultClass \Drupal\content_moderation\ModerationInformation[[api-linebreak]] @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();
}

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