function ConfigCRUDTest::testValueValidation
Tests the validation of configuration object values.
File
- 
              core/tests/ Drupal/ KernelTests/ Core/ Config/ ConfigCRUDTest.php, line 241 
Class
- ConfigCRUDTest
- Tests CRUD operations on configuration objects.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testValueValidation() : void {
  // 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);
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
