public function ConfigCRUDTest::testValueValidation in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php \Drupal\KernelTests\Core\Config\ConfigCRUDTest::testValueValidation()
Tests the validation of configuration object values.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigCRUDTest.php, line 244
Class
- ConfigCRUDTest
- Tests CRUD operations on configuration objects.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testValueValidation() {
// Verify that setData() will catch dotted keys.
try {
$this
->config('namespace.object')
->setData([
'key.value' => 12,
])
->save();
$this
->fail('Expected ConfigValueException was thrown from setData() for value with dotted keys.');
} catch (\Exception $e) {
$this
->assertInstanceOf(ConfigValueException::class, $e);
}
// Verify that set() will catch dotted keys.
try {
$this
->config('namespace.object')
->set('foo', [
'key.value' => 12,
])
->save();
$this
->fail('Expected ConfigValueException was thrown from set() for value with dotted keys.');
} catch (\Exception $e) {
$this
->assertInstanceOf(ConfigValueException::class, $e);
}
}