function RdfMappingConfigEntityUnitTest::testCalculateDependencies

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

@covers ::calculateDependencies

File

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

Class

RdfMappingConfigEntityUnitTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21rdf%21src%21Entity%21RdfMapping.php/class/RdfMapping/8.9.x" title="Config entity for working with RDF mappings." class="local">\Drupal\rdf\Entity\RdfMapping</a> @group rdf

Namespace

Drupal\Tests\rdf\Unit

Code

public function testCalculateDependencies() {
    $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'));
    $values = [
        'targetEntityType' => $target_entity_type_id,
    ];
    $target_entity_type->expects($this->any())
        ->method('getBundleEntityType')
        ->will($this->returnValue(NULL));
    $target_entity_type->expects($this->any())
        ->method('getBundleConfigDependency')
        ->will($this->returnValue([
        'type' => 'module',
        'name' => 'test_module',
    ]));
    $this->entityTypeManager
        ->expects($this->at(0))
        ->method('getDefinition')
        ->with($target_entity_type_id)
        ->will($this->returnValue($target_entity_type));
    $this->entityTypeManager
        ->expects($this->at(1))
        ->method('getDefinition')
        ->with($this->entityTypeId)
        ->will($this->returnValue($this->entityType));
    $this->entityTypeManager
        ->expects($this->at(2))
        ->method('getDefinition')
        ->with($this->entityTypeId)
        ->will($this->returnValue($this->entityType));
    $entity = new RdfMapping($values, $this->entityTypeId);
    $dependencies = $entity->calculateDependencies()
        ->getDependencies();
    $this->assertArrayNotHasKey('config', $dependencies);
    $this->assertContains('test_module', $dependencies['module']);
}

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