function ConfigEntityStorageTest::testLoadMultipleAll

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testLoadMultipleAll()
  2. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testLoadMultipleAll()
  3. 11.x 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 576

Class

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

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testLoadMultipleAll() : void {
    $foo_config_object = $this->prophesize(ImmutableConfig::class);
    $foo_config_object->get()
        ->willReturn([
        'id' => 'foo',
    ]);
    $foo_config_object->get('id')
        ->willReturn('foo');
    $foo_config_object->getCacheContexts()
        ->willReturn([]);
    $foo_config_object->getCacheTags()
        ->willReturn([
        'config:foo',
    ]);
    $foo_config_object->getCacheMaxAge()
        ->willReturn(Cache::PERMANENT);
    $foo_config_object->getName()
        ->willReturn('foo');
    $bar_config_object = $this->prophesize(ImmutableConfig::class);
    $bar_config_object->get()
        ->willReturn([
        'id' => 'bar',
    ]);
    $bar_config_object->get('id')
        ->willReturn('bar');
    $bar_config_object->getCacheContexts()
        ->willReturn([]);
    $bar_config_object->getCacheTags()
        ->willReturn([
        'config:bar',
    ]);
    $bar_config_object->getCacheMaxAge()
        ->willReturn(Cache::PERMANENT);
    $bar_config_object->getName()
        ->willReturn('foo');
    $this->configFactory
        ->listAll('the_provider.the_config_prefix.')
        ->willReturn([
        'the_provider.the_config_prefix.foo',
        'the_provider.the_config_prefix.bar',
    ]);
    $this->configFactory
        ->loadMultiple([
        'the_provider.the_config_prefix.foo',
        'the_provider.the_config_prefix.bar',
    ])
        ->willReturn([
        $foo_config_object->reveal(),
        $bar_config_object->reveal(),
    ]);
    $entities = $this->entityStorage
        ->loadMultiple();
    $expected['foo'] = 'foo';
    $expected['bar'] = 'bar';
    $this->assertContainsOnlyInstancesOf(EntityInterface::class, $entities);
    foreach ($entities as $id => $entity) {
        $this->assertSame($id, $entity->id());
        $this->assertSame($expected[$id], $entity->id());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.