You are here

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

@covers ::load @covers ::postLoad @covers ::mapFromStorageRecords @covers ::doLoadMultiple

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 682
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 testLoad() {
  $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()));
  $entity = $this->entityStorage
    ->load('foo');
  $this
    ->assertInstanceOf('Drupal\\Core\\Entity\\EntityInterface', $entity);
  $this
    ->assertSame('foo', $entity
    ->id());
}