You are here

public function EntityTest::testCalculateDependenciesWithEntityId in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::testCalculateDependenciesWithEntityId()

@covers ::calculateDependencies

File

core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php, line 299
Contains \Drupal\Tests\views\Unit\Plugin\area\EntityTest.

Class

EntityTest
@coversDefaultClass \Drupal\views\Plugin\views\area\Entity @group Entity

Namespace

Drupal\Tests\views\Unit\Plugin\area

Code

public function testCalculateDependenciesWithEntityId() {
  $this
    ->setupEntityManager();
  $entity = $this
    ->getMock('Drupal\\Core\\Entity\\EntityInterface');
  $entity_type = $this
    ->getMock('Drupal\\Core\\Entity\\EntityTypeInterface');
  $entity
    ->expects($this
    ->once())
    ->method('getConfigDependencyName')
    ->willReturn('entity_test:test-bundle:1d52762e-b9d8-4177-908f-572d1a5845a4');
  $this->entityManager
    ->expects($this
    ->once())
    ->method('loadEntityByConfigTarget')
    ->willReturn($entity);
  $this->entityStorage
    ->expects($this
    ->never())
    ->method('loadByProperties');
  $entity_type
    ->expects($this
    ->once())
    ->method('getConfigDependencyKey')
    ->willReturn('content');
  $this->entityManager
    ->expects($this
    ->once())
    ->method('getDefinition')
    ->willReturn($entity_type);
  $options = [
    'target' => 1,
  ];
  $this->entityHandler
    ->init($this->executable, $this->display, $options);
  $this
    ->assertEquals([
    'content' => [
      'entity_test:test-bundle:1d52762e-b9d8-4177-908f-572d1a5845a4',
    ],
  ], $this->entityHandler
    ->calculateDependencies());
}