function EntityDisplayModeBaseUnitTest::testCalculateDependencies

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testCalculateDependencies()
  2. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testCalculateDependencies()
  3. 10 core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testCalculateDependencies()

@covers ::calculateDependencies

File

core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php, line 80

Class

EntityDisplayModeBaseUnitTest
@coversDefaultClass \Drupal\Core\Entity\EntityDisplayModeBase @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testCalculateDependencies() : void {
    $target_entity_type_id = $this->randomMachineName(16);
    $target_entity_type = $this->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
    $target_entity_type->expects($this->any())
        ->method('getProvider')
        ->willReturn('test_module');
    $values = [
        'targetEntityType' => $target_entity_type_id,
    ];
    $this->entityTypeManager
        ->expects($this->exactly(2))
        ->method('getDefinition')
        ->willReturnMap([
        [
            $target_entity_type_id,
            TRUE,
            $target_entity_type,
        ],
        [
            $this->entityType,
            TRUE,
            $this->entityInfo,
        ],
    ]);
    $this->entity = new EntityDisplayModeBaseTestableClass($values, $this->entityType);
    $dependencies = $this->entity
        ->calculateDependencies()
        ->getDependencies();
    $this->assertContains('test_module', $dependencies['module']);
}

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