You are here

public function ConfigEntityStorageTest::testLoadMultipleIds in Zircon Profile 8

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

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

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 797
Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest.

Class

ConfigEntityStorageTest
@coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testLoadMultipleIds() {
  $config_object = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Config')
    ->disableOriginalConstructor()
    ->getMock();
  $config_object
    ->expects($this
    ->exactly(2))
    ->method('get')
    ->will($this
    ->returnValueMap(array(
    array(
      '',
      array(
        'id' => 'foo',
      ),
    ),
    array(
      'id',
      'foo',
    ),
  )));
  $config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheContexts')
    ->willReturn([]);
  $config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheTags')
    ->willReturn([
    'config:foo',
  ]);
  $config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheMaxAge')
    ->willReturn(Cache::PERMANENT);
  $config_object
    ->expects($this
    ->exactly(1))
    ->method('getName')
    ->willReturn('foo');
  $this->configFactory
    ->expects($this
    ->once())
    ->method('loadMultiple')
    ->with(array(
    'the_config_prefix.foo',
  ))
    ->will($this
    ->returnValue(array(
    $config_object,
  )));
  $this->moduleHandler
    ->expects($this
    ->exactly(2))
    ->method('getImplementations')
    ->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());
  }
}