function MappingTest::testInvalidMappingKeyDefinition
Tests invalid mapping key definition.
Attributes
#[TestWith([
FALSE,
42,
"The mapping definition at `foobar` is invalid: its `invalid` key contains a integer. It must be an array.",
])]
#[TestWith([
FALSE,
10.2,
"The mapping definition at `foobar` is invalid: its `invalid` key contains a double. It must be an array.",
])]
#[TestWith([
FALSE,
"type",
"The mapping definition at `foobar` is invalid: its `invalid` key contains a string. It must be an array.",
])]
#[TestWith([
FALSE,
FALSE,
"The mapping definition at `foobar` is invalid: its `invalid` key contains a boolean. It must be an array.",
])]
#[TestWith([
TRUE,
42,
"The mapping definition at `my_module.settings:foobar` is invalid: its `invalid` key contains a integer. It must be an array.",
])]
#[TestWith([
TRUE,
10.2,
"The mapping definition at `my_module.settings:foobar` is invalid: its `invalid` key contains a double. It must be an array.",
])]
#[TestWith([
TRUE,
"type",
"The mapping definition at `my_module.settings:foobar` is invalid: its `invalid` key contains a string. It must be an array.",
])]
#[TestWith([
TRUE,
FALSE,
"The mapping definition at `my_module.settings:foobar` is invalid: its `invalid` key contains a boolean. It must be an array.",
])]
File
-
core/
tests/ Drupal/ KernelTests/ Config/ Schema/ MappingTest.php, line 517
Class
Namespace
Drupal\KernelTests\Config\SchemaCode
public function testInvalidMappingKeyDefinition(bool $has_parent, mixed $invalid_key_definition, string $expected_message) : void {
$definition = new MapDataDefinition([
'type' => 'mapping',
'mapping' => [
'valid' => [
'type' => 'boolean',
'label' => 'This is a valid key-value pair in this mapping',
],
'invalid' => $invalid_key_definition,
],
]);
$parent = NULL;
if ($has_parent) {
$parent = new Mapping(new MapDataDefinition([
'type' => 'mapping',
'mapping' => [],
]), 'my_module.settings');
}
$this->expectException(\LogicException::class);
$this->expectExceptionMessage($expected_message);
new Mapping($definition, 'foobar', $parent);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.