diff --git a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php index a47156f..cc76a043 100644 --- a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php @@ -126,6 +126,7 @@ public function testRenderWithId() { 'tokenize' => FALSE, ]; + /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $this->getMock('Drupal\Core\Entity\EntityInterface'); $entity->expects($this->once()) ->method('access') @@ -133,9 +134,8 @@ public function testRenderWithId() { $this->entityStorage->expects($this->never()) ->method('loadByProperties'); - $this->entityStorage->expects($this->once()) - ->method('load') - ->with(1) + $this->entityManager->expects($this->any()) + ->method('loadEntityByConfigTarget') ->willReturn($entity); $this->entityViewBuilder->expects($this->once()) ->method('view') @@ -206,10 +206,9 @@ public function testRenderWithUuid() { $this->entityStorage->expects($this->never()) ->method('load'); - $this->entityStorage->expects($this->once()) - ->method('loadByProperties') - ->with(['uuid' => $uuid]) - ->willReturn([$entity]); + $this->entityManager->expects($this->once()) + ->method('loadEntityByConfigTarget') + ->willReturn($entity); $this->entityViewBuilder->expects($this->once()) ->method('view') ->with($entity, 'default') @@ -243,18 +242,27 @@ public function testCalculateDependenciesWithUuid() { $uuid = '1d52762e-b9d8-4177-908f-572d1a5845a4'; $entity = $this->getMock('Drupal\Core\Entity\EntityInterface'); + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); $entity->expects($this->atLeastOnce()) ->method('bundle') ->willReturn('test-bundle'); + $entity->expects($this->once()) + ->method('getConfigDependencyName') + ->willReturn('entity_test:test-bundle:1d52762e-b9d8-4177-908f-572d1a5845a4'); $entity->expects($this->atLeastOnce()) ->method('uuid') ->willReturn($uuid); $this->entityStorage->expects($this->never()) ->method('load'); - $this->entityStorage->expects($this->once()) - ->method('loadByProperties') - ->with(['uuid' => $uuid]) - ->willReturn([$entity]); + $this->entityManager->expects($this->once()) + ->method('loadEntityByConfigTarget') + ->willReturn($entity); + $entity_type->expects($this->once()) + ->method('getConfigDependencyKey') + ->willReturn('content'); + $this->entityManager->expects($this->once()) + ->method('getDefinition') + ->willReturn($entity_type); $options = [ 'target' => $uuid, @@ -272,18 +280,27 @@ public function testCalculateDependenciesWithEntityId() { $uuid = '1d52762e-b9d8-4177-908f-572d1a5845a4'; $entity = $this->getMock('Drupal\Core\Entity\EntityInterface'); + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); $entity->expects($this->atLeastOnce()) ->method('bundle') ->willReturn('test-bundle'); + $entity->expects($this->once()) + ->method('getConfigDependencyName') + ->willReturn('entity_test:test-bundle:1d52762e-b9d8-4177-908f-572d1a5845a4'); $entity->expects($this->atLeastOnce()) ->method('uuid') ->willReturn($uuid); - $this->entityStorage->expects($this->once()) - ->method('load') - ->with(1) + $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,