function ConfigEntityMapperTest::testEntityGetterAndSetter
Same name in other branches
- 8.9.x core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigEntityMapperTest::testEntityGetterAndSetter()
- 10 core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigEntityMapperTest::testEntityGetterAndSetter()
- 11.x core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigEntityMapperTest::testEntityGetterAndSetter()
Tests ConfigEntityMapper::setEntity() and ConfigEntityMapper::getEntity().
File
-
core/
modules/ config_translation/ tests/ src/ Unit/ ConfigEntityMapperTest.php, line 112
Class
- ConfigEntityMapperTest
- Tests the functionality provided by the configuration entity mapper.
Namespace
Drupal\Tests\config_translation\UnitCode
public function testEntityGetterAndSetter() {
$this->entity
->expects($this->once())
->method('id')
->with()
->willReturn('entity_id');
$entity_type = $this->createMock('Drupal\\Core\\Config\\Entity\\ConfigEntityTypeInterface');
$entity_type->expects($this->any())
->method('getConfigPrefix')
->willReturn('config_prefix');
$this->entityTypeManager
->expects($this->once())
->method('getDefinition')
->with('configurable_language')
->willReturn($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->assertContains('config_prefix.entity_id', $plugin_definition['names']);
// Make sure setEntity() returns FALSE when called a second time.
$result = $this->configEntityMapper
->setEntity($this->entity);
$this->assertFalse($result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.