You are here

public function ConfigEntityStorageTest::testLoad in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testLoad()
  2. 9 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 546

Class

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

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testLoad() {
  $config_object = $this
    ->prophesize(ImmutableConfig::class);
  $config_object
    ->get()
    ->willReturn([
    'id' => 'foo',
  ]);
  $config_object
    ->get('id')
    ->willReturn('foo');
  $config_object
    ->getCacheContexts()
    ->willReturn([]);
  $config_object
    ->getCacheTags()
    ->willReturn([
    'config:foo',
  ]);
  $config_object
    ->getCacheMaxAge()
    ->willReturn(Cache::PERMANENT);
  $config_object
    ->getName()
    ->willReturn('foo');
  $this->configFactory
    ->loadMultiple([
    'the_provider.the_config_prefix.foo',
  ])
    ->willReturn([
    $config_object
      ->reveal(),
  ]);
  $entity = $this->entityStorage
    ->load('foo');
  $this
    ->assertInstanceOf(EntityInterface::class, $entity);
  $this
    ->assertSame('foo', $entity
    ->id());
  $this
    ->expectException(\AssertionError::class);
  $this
    ->expectExceptionMessage(sprintf('Cannot load the "%s" entity with NULL ID.', $this->entityTypeId));
  $this->entityStorage
    ->load(NULL);
}