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. 10 core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testCalculateDependencies()
  3. 11.x 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 75

Class

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

Namespace

Drupal\Tests\Core\Config\Entity

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,
    ];
    $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->entityType)
        ->will($this->returnValue($this->entityInfo));
    $this->entity = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityDisplayModeBase')
        ->setConstructorArgs([
        $values,
        $this->entityType,
    ])
        ->setMethods([
        'getFilterFormat',
    ])
        ->getMock();
    $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.