You are here

public function ConfigEntityStorageTest::testLoadMultipleAll 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::testLoadMultipleAll()

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

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 724
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 testLoadMultipleAll() {
  $foo_config_object = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Config')
    ->disableOriginalConstructor()
    ->getMock();
  $foo_config_object
    ->expects($this
    ->exactly(2))
    ->method('get')
    ->will($this
    ->returnValueMap(array(
    array(
      '',
      array(
        'id' => 'foo',
      ),
    ),
    array(
      'id',
      'foo',
    ),
  )));
  $foo_config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheContexts')
    ->willReturn([]);
  $foo_config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheTags')
    ->willReturn([
    'config:foo',
  ]);
  $foo_config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheMaxAge')
    ->willReturn(Cache::PERMANENT);
  $foo_config_object
    ->expects($this
    ->exactly(1))
    ->method('getName')
    ->willReturn('foo');
  $bar_config_object = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Config')
    ->disableOriginalConstructor()
    ->getMock();
  $bar_config_object
    ->expects($this
    ->exactly(2))
    ->method('get')
    ->will($this
    ->returnValueMap(array(
    array(
      '',
      array(
        'id' => 'bar',
      ),
    ),
    array(
      'id',
      'bar',
    ),
  )));
  $bar_config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheContexts')
    ->willReturn([]);
  $bar_config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheTags')
    ->willReturn([
    'config:bar',
  ]);
  $bar_config_object
    ->expects($this
    ->exactly(1))
    ->method('getCacheMaxAge')
    ->willReturn(Cache::PERMANENT);
  $bar_config_object
    ->expects($this
    ->exactly(1))
    ->method('getName')
    ->willReturn('foo');
  $this->configFactory
    ->expects($this
    ->once())
    ->method('listAll')
    ->with('the_config_prefix.')
    ->will($this
    ->returnValue(array(
    'the_config_prefix.foo',
    'the_config_prefix.bar',
  )));
  $this->configFactory
    ->expects($this
    ->once())
    ->method('loadMultiple')
    ->with(array(
    'the_config_prefix.foo',
    'the_config_prefix.bar',
  ))
    ->will($this
    ->returnValue(array(
    $foo_config_object,
    $bar_config_object,
  )));
  $this->moduleHandler
    ->expects($this
    ->exactly(2))
    ->method('getImplementations')
    ->will($this
    ->returnValue(array()));
  $entities = $this->entityStorage
    ->loadMultiple();
  $expected['foo'] = 'foo';
  $expected['bar'] = 'bar';
  foreach ($entities as $id => $entity) {
    $this
      ->assertInstanceOf('Drupal\\Core\\Entity\\EntityInterface', $entity);
    $this
      ->assertSame($id, $entity
      ->id());
    $this
      ->assertSame($expected[$id], $entity
      ->id());
  }
}