diff --git a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php index 1c5b043..421071b 100644 --- a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php +++ b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php @@ -13,8 +13,6 @@ use Drupal\Core\Config\Schema\SchemaCheckTrait; use Drupal\Core\Config\Schema\SchemaIncompleteException; use Drupal\Core\Config\TypedConfigManagerInterface; -use Drupal\Core\Database\ConnectionNotDefinedException; -use Drupal\Core\Database\Database; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -55,15 +53,16 @@ public function __construct(TypedConfigManagerInterface $typed_manager) { } /** - * Removes stale static cache entries when configuration is saved. + * Checks that configuration complies with its schema on config save. * * @param ConfigCrudEvent $event * The configuration event. + * + * @throws \Drupal\Core\Config\Schema\SchemaIncompleteException + * Exception thrown when configuration does not match its schema. */ public function onConfigSave(ConfigCrudEvent $event) { $saved_config = $event->getConfig(); - // Check that we have a valid for all config saved during tests. Do not - // validate the same config / data. $name = $saved_config->getName(); $data = $saved_config->get(); $checksum = crc32(serialize($data)); diff --git a/core/modules/config/src/Tests/SchemaConfigListenerTest.php b/core/modules/config/src/Tests/SchemaConfigListenerTest.php index 070e268..4796547 100644 --- a/core/modules/config/src/Tests/SchemaConfigListenerTest.php +++ b/core/modules/config/src/Tests/SchemaConfigListenerTest.php @@ -31,7 +31,7 @@ class SchemaConfigListenerTest extends KernelTestBase { /** * Tests \Drupal\Core\Config\Testing\ConfigSchemaChecker. */ - public function testTrait() { + public function testConfigSchemaChecker() { // Test a non existing schema. $msg = 'Expected SchemaIncompleteException thrown'; try { @@ -43,6 +43,7 @@ public function testTrait() { $this->assertEqual('No schema for config_schema_test.noschema', $e->getMessage()); } + // Test a valid schema. $msg = 'Unexpected SchemaIncompleteException thrown'; $config = \Drupal::config('config_test.types')->set('int', 10); try { @@ -53,6 +54,7 @@ public function testTrait() { $this->fail($msg); } + // Test an invalid schema. $msg = 'Expected SchemaIncompleteException thrown'; $config = \Drupal::config('config_test.types') ->set('foo', 'bar') diff --git a/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php index d38b055..86e28d9 100644 --- a/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php +++ b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php @@ -32,7 +32,7 @@ class SchemaConfigListenerWebTest extends WebTestBase { /** * Tests \Drupal\Core\Config\Testing\ConfigSchemaChecker. */ - public function testTrait() { + public function testConfigSchemaChecker() { // Test a non existing schema. $msg = 'Expected SchemaIncompleteException thrown'; try { @@ -44,6 +44,7 @@ public function testTrait() { $this->assertEqual('No schema for config_schema_test.noschema', $e->getMessage()); } + // Test a valid schema. $msg = 'Unexpected SchemaIncompleteException thrown'; $config = \Drupal::config('config_test.types')->set('int', 10); try { @@ -54,6 +55,7 @@ public function testTrait() { $this->fail($msg); } + // Test an invalid schema. $msg = 'Expected SchemaIncompleteException thrown'; $config = \Drupal::config('config_test.types') ->set('foo', 'bar') @@ -67,6 +69,7 @@ public function testTrait() { $this->pass('Schema errors for config_test.types with the following errors: config_test.types:foo: Missing schema., config_test.types:array: Variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence.'); } + // Test that the config event listener is working in the child site. $this->drupalGet('config_test/schema_listener'); $this->assertText('No schema for config_schema_test.noschema'); }