You are here

public function ModerationDeriverTest::testGetDerivativeDefinitions in Workbench Moderation to Content Moderation 8.2

@covers ::getDerivativeDefinitions

@dataProvider getDerivativeDefinitionsProvider

File

tests/src/Unit/Plugin/Deriver/ModerationDeriverTest.php, line 36

Class

ModerationDeriverTest
@coversDefaultClass \Drupal\wbm2cm\Plugin\Deriver\ModerationDeriver @group wbm2cm

Namespace

Drupal\Tests\wbm2cm\Unit\Plugin\Deriver

Code

public function testGetDerivativeDefinitions(array $definitions, $expected_count, $expected_derivatives) {
  foreach ($definitions as $entity_type_id => $flags) {
    $definitions[$entity_type_id] = $this
      ->mockEntityType($flags, $entity_type_id);
  }
  $this->entityTypeManager
    ->getDefinitions()
    ->willReturn($definitions);
  $plugin_definition = [
    'id' => $this
      ->randomMachineName(),
    'class' => 'It worked!',
    'source_module' => 'wbm2cm',
  ];
  $deriver = new ModerationDeriver($this->entityTypeManager
    ->reveal(), array_keys($definitions));
  $derivatives = $deriver
    ->getDerivativeDefinitions($plugin_definition);
  $this
    ->assertCount($expected_count, $derivatives);
  foreach ($expected_derivatives as $id) {
    $this
      ->assertEquals($plugin_definition, $derivatives[$id]);
  }
}