You are here

public function RdfMappingConfigEntityUnitTest::testCalculateDependenciesWithEntityBundle in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php \Drupal\Tests\rdf\Unit\RdfMappingConfigEntityUnitTest::testCalculateDependenciesWithEntityBundle()
  2. 10 core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php \Drupal\Tests\rdf\Unit\RdfMappingConfigEntityUnitTest::testCalculateDependenciesWithEntityBundle()

@covers ::calculateDependencies

File

core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php, line 100

Class

RdfMappingConfigEntityUnitTest
@coversDefaultClass \Drupal\rdf\Entity\RdfMapping @group rdf

Namespace

Drupal\Tests\rdf\Unit

Code

public function testCalculateDependenciesWithEntityBundle() {
  $target_entity_type_id = $this
    ->randomMachineName(16);
  $target_entity_type = $this
    ->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $target_entity_type
    ->expects($this
    ->any())
    ->method('getProvider')
    ->will($this
    ->returnValue('test_module'));
  $bundle_id = $this
    ->randomMachineName(10);
  $values = [
    'targetEntityType' => $target_entity_type_id,
    'bundle' => $bundle_id,
  ];
  $target_entity_type
    ->expects($this
    ->any())
    ->method('getBundleConfigDependency')
    ->will($this
    ->returnValue([
    'type' => 'config',
    'name' => 'test_module.type.' . $bundle_id,
  ]));
  $this->entityTypeManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->willReturnMap([
    [
      $target_entity_type_id,
      TRUE,
      $target_entity_type,
    ],
    [
      $this->entityTypeId,
      TRUE,
      $this->entityType,
    ],
  ]);
  $entity = new RdfMapping($values, $this->entityTypeId);
  $dependencies = $entity
    ->calculateDependencies()
    ->getDependencies();
  $this
    ->assertContains('test_module.type.' . $bundle_id, $dependencies['config']);
  $this
    ->assertContains('test_module', $dependencies['module']);
}