You are here

function ConfigCRUDTest::testValueValidation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/ConfigCRUDTest.php \Drupal\config\Tests\ConfigCRUDTest::testValueValidation()

Tests the validation of configuration object values.

File

core/modules/config/src/Tests/ConfigCRUDTest.php, line 220
Contains \Drupal\config\Tests\ConfigCRUDTest.

Class

ConfigCRUDTest
Tests CRUD operations on configuration objects.

Namespace

Drupal\config\Tests

Code

function testValueValidation() {

  // Verify that setData() will catch dotted keys.
  $message = 'Expected ConfigValueException was thrown from setData() for value with dotted keys.';
  try {
    $this
      ->config('namespace.object')
      ->setData(array(
      'key.value' => 12,
    ))
      ->save();
    $this
      ->fail($message);
  } catch (ConfigValueException $e) {
    $this
      ->pass($message);
  }

  // Verify that set() will catch dotted keys.
  $message = 'Expected ConfigValueException was thrown from set() for value with dotted keys.';
  try {
    $this
      ->config('namespace.object')
      ->set('foo', array(
      'key.value' => 12,
    ))
      ->save();
    $this
      ->fail($message);
  } catch (ConfigValueException $e) {
    $this
      ->pass($message);
  }
}