You are here

public function SqlContentEntityStorageTest::testLoadMultiplePersistentCached in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testLoadMultiplePersistentCached()

@covers ::doLoadMultiple @covers ::buildCacheId @covers ::getFromPersistentCache

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php, line 1060
Contains \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest.

Class

SqlContentEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorage @group Entity

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function testLoadMultiplePersistentCached() {
  $this
    ->setUpModuleHandlerNoImplementations();
  $key = 'values:' . $this->entityTypeId . ':1';
  $id = 1;
  $entity = $this
    ->getMockBuilder('\\Drupal\\Tests\\Core\\Entity\\Sql\\SqlContentEntityStorageTestEntityInterface')
    ->getMockForAbstractClass();
  $entity
    ->expects($this
    ->any())
    ->method('id')
    ->will($this
    ->returnValue($id));
  $this->entityType
    ->expects($this
    ->atLeastOnce())
    ->method('isPersistentlyCacheable')
    ->will($this
    ->returnValue(TRUE));
  $this->entityType
    ->expects($this
    ->atLeastOnce())
    ->method('id')
    ->will($this
    ->returnValue($this->entityTypeId));
  $this->entityType
    ->expects($this
    ->atLeastOnce())
    ->method('getClass')
    ->will($this
    ->returnValue(get_class($entity)));
  $this->cache
    ->expects($this
    ->once())
    ->method('getMultiple')
    ->with(array(
    $key,
  ))
    ->will($this
    ->returnValue(array(
    $key => (object) array(
      'data' => $entity,
    ),
  )));
  $this->cache
    ->expects($this
    ->never())
    ->method('set');
  $this
    ->setUpEntityStorage();
  $entities = $this->entityStorage
    ->loadMultiple(array(
    $id,
  ));
  $this
    ->assertEquals($entity, $entities[$id]);
}