You are here

public function KeyValueEntityStorageTest::testLoadMultipleIds in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testLoadMultipleIds()

@covers ::loadMultiple @covers ::postLoad @covers ::mapFromStorageRecords @covers ::doLoadMultiple

File

core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php, line 571
Contains \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest.

Class

KeyValueEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage @group Entity

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

public function testLoadMultipleIds() {
  $entity = $this
    ->getMockEntity('Drupal\\Core\\Entity\\Entity', array(
    array(
      'id' => 'foo',
    ),
  ));
  $this->entityType
    ->expects($this
    ->once())
    ->method('getClass')
    ->will($this
    ->returnValue(get_class($entity)));
  $this
    ->setUpKeyValueEntityStorage();
  $expected[] = $entity;
  $this->keyValueStore
    ->expects($this
    ->once())
    ->method('getMultiple')
    ->with(array(
    'foo',
  ))
    ->will($this
    ->returnValue(array(
    array(
      'id' => 'foo',
    ),
  )));
  $this->moduleHandler
    ->expects($this
    ->at(0))
    ->method('getImplementations')
    ->with('entity_load')
    ->will($this
    ->returnValue(array()));
  $this->moduleHandler
    ->expects($this
    ->at(1))
    ->method('getImplementations')
    ->with('test_entity_type_load')
    ->will($this
    ->returnValue(array()));
  $entities = $this->entityStorage
    ->loadMultiple(array(
    'foo',
  ));
  foreach ($entities as $id => $entity) {
    $this
      ->assertInstanceOf('Drupal\\Core\\Entity\\EntityInterface', $entity);
    $this
      ->assertSame($id, $entity
      ->id());
  }
}