Issue #2565031 by penyaskito: Expose $entity in ConfigEntityMapper
parent
3473bd5d3a
commit
068f6ad739
|
@ -116,6 +116,16 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
$this->setEntity($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entity instance for this mapper.
|
||||
*
|
||||
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
|
||||
* The configuration entity.
|
||||
*/
|
||||
public function getEntity() {
|
||||
return $this->entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entity instance for this mapper.
|
||||
*
|
||||
|
|
|
@ -99,9 +99,9 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests ConfigEntityMapper::setEntity().
|
||||
* Tests ConfigEntityMapper::setEntity() and ConfigEntityMapper::getEntity().
|
||||
*/
|
||||
public function testSetEntity() {
|
||||
public function testEntityGetterAndSetter() {
|
||||
$this->entity
|
||||
->expects($this->once())
|
||||
->method('id')
|
||||
|
@ -119,9 +119,15 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
->with('configurable_language')
|
||||
->will($this->returnValue($entity_type));
|
||||
|
||||
// No entity is set.
|
||||
$this->assertNull($this->configEntityMapper->getEntity());
|
||||
|
||||
$result = $this->configEntityMapper->setEntity($this->entity);
|
||||
$this->assertTrue($result);
|
||||
|
||||
// Ensure that the getter provides the entity.
|
||||
$this->assertEquals($this->entity, $this->configEntityMapper->getEntity());
|
||||
|
||||
// Ensure that the configuration name was added to the mapper.
|
||||
$plugin_definition = $this->configEntityMapper->getPluginDefinition();
|
||||
$this->assertTrue(in_array('config_prefix.entity_id', $plugin_definition['names']));
|
||||
|
|
Loading…
Reference in New Issue