diff --git a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php index db80944..332c77b 100644 --- a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php +++ b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php @@ -66,7 +66,17 @@ public function onConfigSave(ConfigCrudEvent $event) { $name = $saved_config->getName(); $data = $saved_config->get(); $checksum = crc32(serialize($data)); - if (!isset($this->checked[$name . ':' . $checksum])) { + $exceptions = array( + // Following are used to test lack of or partial schema. Where partial + // schema is provided, that is explicitly tested in specific tests. + 'config_schema_test.noschema', + 'config_schema_test.someschema', + 'config_schema_test.schema_data_types', + 'config_schema_test.no_schema_data_types', + // Used to test application of schema to filtering of configuration. + 'config_test.dynamic.system', + ); + if (!in_array($name, $exceptions) && !isset($this->checked[$name . ':' . $checksum])) { $this->checked[$name . ':' . $checksum] = TRUE; $errors = $this->checkConfigSchema($this->typedManager, $name, $data); if ($errors === FALSE) { diff --git a/core/modules/config/src/Tests/ConfigCRUDTest.php b/core/modules/config/src/Tests/ConfigCRUDTest.php index 57d556a..4c3642e 100644 --- a/core/modules/config/src/Tests/ConfigCRUDTest.php +++ b/core/modules/config/src/Tests/ConfigCRUDTest.php @@ -24,6 +24,15 @@ class ConfigCRUDTest extends KernelTestBase { /** + * Exempt from strict schema checking. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = FALSE; + + /** * Modules to enable. * * @var array @@ -178,7 +187,7 @@ function testNameValidation() { $config->save(); $this->pass($message); } - catch (\Exception $e) { + catch (ConfigNameException $e) { $this->fail($message); } diff --git a/core/modules/config/src/Tests/ConfigDependencyTest.php b/core/modules/config/src/Tests/ConfigDependencyTest.php index 88abef7..e4fcf2f 100644 --- a/core/modules/config/src/Tests/ConfigDependencyTest.php +++ b/core/modules/config/src/Tests/ConfigDependencyTest.php @@ -17,6 +17,15 @@ class ConfigDependencyTest extends KernelTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php b/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php index 5e52cfe..dcc6341 100644 --- a/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php +++ b/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php @@ -11,6 +11,15 @@ */ class ConfigEntityNormalizeTest extends KernelTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + public static $modules = array('config_test'); protected function setUp() { diff --git a/core/modules/config/src/Tests/ConfigEventsTest.php b/core/modules/config/src/Tests/ConfigEventsTest.php index b4f7279..a967128 100644 --- a/core/modules/config/src/Tests/ConfigEventsTest.php +++ b/core/modules/config/src/Tests/ConfigEventsTest.php @@ -19,6 +19,15 @@ class ConfigEventsTest extends KernelTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/config/src/Tests/ConfigFileContentTest.php b/core/modules/config/src/Tests/ConfigFileContentTest.php index 35ca948..537fdd3 100644 --- a/core/modules/config/src/Tests/ConfigFileContentTest.php +++ b/core/modules/config/src/Tests/ConfigFileContentTest.php @@ -16,6 +16,16 @@ * @group config */ class ConfigFileContentTest extends KernelTestBase { + + /** + * Exempt from strict schema checking. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = FALSE; + /** * Tests setting, writing, and reading of a configuration setting. */ diff --git a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php index ea2face..a7cae49 100644 --- a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php +++ b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php @@ -23,6 +23,15 @@ class ConfigImportRenameValidationTest extends KernelTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Config Importer object used for testing. * * @var \Drupal\Core\Config\ConfigImporter diff --git a/core/modules/config/src/Tests/ConfigInstallTest.php b/core/modules/config/src/Tests/ConfigInstallTest.php index 532d194..745950a 100644 --- a/core/modules/config/src/Tests/ConfigInstallTest.php +++ b/core/modules/config/src/Tests/ConfigInstallTest.php @@ -16,6 +16,16 @@ * @see \Drupal\Core\Config\ConfigInstaller */ class ConfigInstallTest extends KernelTestBase { + + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + protected function setUp() { parent::setUp(); diff --git a/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php b/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php index 2371a88..2246612 100644 --- a/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php @@ -18,6 +18,15 @@ class ConfigLanguageOverrideTest extends KernelTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/config/src/Tests/ConfigOverrideTest.php b/core/modules/config/src/Tests/ConfigOverrideTest.php index 38ba0a1..76c8203 100644 --- a/core/modules/config/src/Tests/ConfigOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigOverrideTest.php @@ -17,6 +17,15 @@ class ConfigOverrideTest extends KernelTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/config/src/Tests/ConfigSchemaTest.php b/core/modules/config/src/Tests/ConfigSchemaTest.php index 202b552..e87a984 100644 --- a/core/modules/config/src/Tests/ConfigSchemaTest.php +++ b/core/modules/config/src/Tests/ConfigSchemaTest.php @@ -21,6 +21,15 @@ class ConfigSchemaTest extends KernelTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/config/src/Tests/SchemaCheckTraitTest.php b/core/modules/config/src/Tests/SchemaCheckTraitTest.php index 450d4f1..db3be3c 100644 --- a/core/modules/config/src/Tests/SchemaCheckTraitTest.php +++ b/core/modules/config/src/Tests/SchemaCheckTraitTest.php @@ -17,6 +17,16 @@ * @group config */ class SchemaCheckTraitTest extends KernelTestBase { + + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + use SchemaCheckTrait; /** diff --git a/core/modules/config/src/Tests/SchemaConfigListenerTest.php b/core/modules/config/src/Tests/SchemaConfigListenerTest.php index 84bf60e..579d916 100644 --- a/core/modules/config/src/Tests/SchemaConfigListenerTest.php +++ b/core/modules/config/src/Tests/SchemaConfigListenerTest.php @@ -35,12 +35,12 @@ public function testConfigSchemaChecker() { // Test a non-existing schema. $message = 'Expected SchemaIncompleteException thrown'; try { - \Drupal::config('config_schema_test.noschema')->set('foo', 'bar')->save(); + \Drupal::config('config_schema_test.schemaless')->set('foo', 'bar')->save(); $this->fail($message); } catch (SchemaIncompleteException $e) { $this->pass($message); - $this->assertEqual('No schema for config_schema_test.noschema', $e->getMessage()); + $this->assertEqual('No schema for config_schema_test.schemaless', $e->getMessage()); } // Test a valid schema. diff --git a/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php index 10ddc7b..878665c 100644 --- a/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php +++ b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php @@ -36,12 +36,12 @@ public function testConfigSchemaChecker() { // Test a non-existing schema. $msg = 'Expected SchemaIncompleteException thrown'; try { - \Drupal::config('config_schema_test.noschema')->set('foo', 'bar')->save(); + \Drupal::config('config_schema_test.schemaless')->set('foo', 'bar')->save(); $this->fail($msg); } catch (SchemaIncompleteException $e) { $this->pass($msg); - $this->assertEqual('No schema for config_schema_test.noschema', $e->getMessage()); + $this->assertEqual('No schema for config_schema_test.schemaless', $e->getMessage()); } // Test a valid schema. @@ -71,7 +71,7 @@ public function testConfigSchemaChecker() { // 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'); + $this->assertText('No schema for config_schema_test.schemaless'); } } diff --git a/core/modules/config/tests/config_collection_install_test/config/schema/config_collection_install_test.schema.yml b/core/modules/config/tests/config_collection_install_test/config/schema/config_collection_install_test.schema.yml new file mode 100644 index 0000000..6e93f97 --- /dev/null +++ b/core/modules/config/tests/config_collection_install_test/config/schema/config_collection_install_test.schema.yml @@ -0,0 +1,7 @@ +config_collection_install_test.test: + type: mapping + label: 'Collection test' + mapping: + collection: + type: string + label: 'Collection' diff --git a/core/modules/config/tests/config_events_test/config/schema/config_events_test.schema.yml b/core/modules/config/tests/config_events_test/config/schema/config_events_test.schema.yml new file mode 100644 index 0000000..e3005b1 --- /dev/null +++ b/core/modules/config/tests/config_events_test/config/schema/config_events_test.schema.yml @@ -0,0 +1,7 @@ +config_events_test.test: + type: mapping + label: 'Configuration events test' + mapping: + key: + type: string + label: 'Value' diff --git a/core/modules/config/tests/config_test/config/schema/config_test.schema.yml b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml index 6b375af..9240d4b 100644 --- a/core/modules/config/tests/config_test/config/schema/config_test.schema.yml +++ b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml @@ -105,6 +105,44 @@ config_test.system: foo: type: string label: 'Foo' + baz: + type: string + label: 'Baz' '404': type: string label: '404' + +config_test.new: + type: mapping + label: 'Configuration test' + mapping: + key: + type: string + label: 'Test setting' + new_key: + type: string + label: 'Test setting' + uuid: + type: string + label: 'UUID' + +config_test.old: + type: config_test.new + +config_test.foo: + type: mapping + label: 'Configuration test' + mapping: + value: + type: mapping + label: 'Value' + mapping: + key: + type: string + label: 'Key' + label: + type: label + label: 'Label' + +config_test.bar: + type: config_test.foo diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php index 2cbdd91..022b1f1 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php @@ -43,6 +43,6 @@ class ConfigQueryTest extends ConfigTest { * * @var array */ - public $array; + public $array = array(); } diff --git a/core/modules/config/tests/config_test/src/SchemaListenerController.php b/core/modules/config/tests/config_test/src/SchemaListenerController.php index fe91ade..baf2970 100644 --- a/core/modules/config/tests/config_test/src/SchemaListenerController.php +++ b/core/modules/config/tests/config_test/src/SchemaListenerController.php @@ -20,7 +20,7 @@ class SchemaListenerController extends ControllerBase { */ public function test() { try { - $this->config('config_schema_test.noschema')->set('foo', 'bar')->save(); + $this->config('config_schema_test.schemaless')->set('foo', 'bar')->save(); } catch (SchemaIncompleteException $e) { return [