function ConfigEntityBaseUnitTest::testLoadOverrideFree
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testLoadOverrideFree()
Tests ConfigEntityBase::loadOverrideFree().
When called statically on a subclass of ConfigEntityBase.
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityBaseUnitTest.php, line 292
Class
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testLoadOverrideFree() : 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('loadOverrideFree')
->with($this->id)
->willReturn($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::loadOverrideFree() statically and check that it
// returns the mock entity.
$this->assertSame($this->entity, $class_name::loadOverrideFree($this->id));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.