function EntityConverterTest::testConvertDynamicConfigEntityRejectsNonAscii
Tests convert() for dynamic config entity types.
@legacy-covers ::convert
File
-
core/
tests/ Drupal/ KernelTests/ Core/ ParamConverter/ EntityConverterTest.php, line 118
Class
- EntityConverterTest
- Tests the entity param converter.
Namespace
Drupal\KernelTests\Core\ParamConverterCode
public function testConvertDynamicConfigEntityRejectsNonAscii() : void {
$converter = $this->container
->get('paramconverter.entity');
$config_entity = $this->container
->get('entity_type.manager')
->getStorage('config_test')
->create([
'id' => 'test_id',
'label' => 'Test',
]);
$config_entity->save();
$definition = [
'type' => 'entity:{entity_type}',
];
// Test that the entity is loaded.
$defaults = [
'example' => "test_id",
'entity_type' => 'config_test',
];
$converted = $converter->convert("test_id", $definition, 'example', $defaults);
$this->assertSame('test_id', $converted->id());
// Test that an invalid entity ID is rejected without triggering an
// exception.
$defaults = [
'example' => "invalid\x80value",
'entity_type' => 'config_test',
];
$converted = $converter->convert("invalid\x80value", $definition, 'example', $defaults);
$this->assertNull($converted);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.