function ConfigEntityStorageTest::testLoadMultipleAll

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testLoadMultipleAll()
  2. 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testLoadMultipleAll()
  3. 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testLoadMultipleAll()
  4. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testLoadMultipleAll()

Tests load multiple all.

@legacy-covers ::loadMultiple @legacy-covers ::postLoad @legacy-covers ::mapFromStorageRecords @legacy-covers ::doLoadMultiple

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 612

Class

ConfigEntityStorageTest
Tests Drupal\Core\Config\Entity\ConfigEntityStorage.

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.