Issue #3035980 by jhedstrom: Provide a better error when a NULL is passed to EntityStorageBase::load()
parent
2adeb979e2
commit
4dfdaaed2e
|
@ -246,6 +246,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function load($id) {
|
||||
assert(!is_null($id), 'Cannot load a NULL ID.');
|
||||
$entities = $this->loadMultiple([$id]);
|
||||
return isset($entities[$id]) ? $entities[$id] : NULL;
|
||||
}
|
||||
|
|
|
@ -559,6 +559,9 @@ class ConfigEntityStorageTest extends UnitTestCase {
|
|||
$entity = $this->entityStorage->load('foo');
|
||||
$this->assertInstanceOf(EntityInterface::class, $entity);
|
||||
$this->assertSame('foo', $entity->id());
|
||||
|
||||
$this->setExpectedException(\AssertionError::class, 'Cannot load a NULL ID.');
|
||||
$this->entityStorage->load(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue