function ConfigEntityBaseUnitTest::testLoadMultipleOverrideFree

Tests ConfigEntityBase::loadMultipleOverrideFree().

When called statically on a subclass of ConfigEntityBase.

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php, line 299

Class

ConfigEntityBaseUnitTest
Tests Drupal\Core\Config\Entity\ConfigEntityBase.

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testLoadMultipleOverrideFree() : void {
  $class_name = get_class($this->entity);
  $entity_type_repository = $this->createMock(EntityTypeRepositoryInterface::class);
  $entity_type_repository->expects($this->once())
    ->method('getEntityTypeFromClass')
    ->with($class_name)
    ->willReturn($this->entityTypeId);
  $storage = $this->createMock(ConfigEntityStorageInterface::class);
  $storage->expects($this->once())
    ->method('loadMultipleOverrideFree')
    ->with([
    $this->id,
  ])
    ->willReturn([
    $this->id => $this->entity,
  ]);
  $this->entityTypeManager = $this->createStub(EntityTypeManagerInterface::class);
  $this->entityTypeManager
    ->method('getDefinition')
    ->willReturn($this->entityType);
  $this->entityTypeManager
    ->method('getStorage')
    ->willReturn($storage);
  \Drupal::getContainer()->set('entity_type.manager', $this->entityTypeManager);
  \Drupal::getContainer()->set('entity_type.repository', $entity_type_repository);
  // Call ConfigEntityBase::loadMultipleOverrideFree() statically and check that it
  // returns the mock entity.
  $this->assertSame([
    $this->id => $this->entity,
  ], $class_name::loadMultipleOverrideFree([
    $this->id,
  ]));
}

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