.../tests/src/Functional/ConfigImportAllTest.php | 3 + .../Drupal/KernelTests/Config/TypedConfigTest.php | 7 +- .../KernelTests/Core/Config/DefaultConfigTest.php | 76 ---------------------- .../Core/Config/SchemaCheckTraitTest.php | 5 ++ 4 files changed, 14 insertions(+), 77 deletions(-) diff --git a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php index c04c0eb9ac..10e6d47101 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php @@ -11,6 +11,9 @@ /** * Tests the largest configuration import possible with all available modules. * + * Note that the use of SchemaCheckTestTrait means that the schema conformance + * of all default configuration is also tested. + * * @group config */ class ConfigImportAllTest extends ModuleTestBase { diff --git a/core/tests/Drupal/KernelTests/Config/TypedConfigTest.php b/core/tests/Drupal/KernelTests/Config/TypedConfigTest.php index adba8b8e0b..47bd91b1e0 100644 --- a/core/tests/Drupal/KernelTests/Config/TypedConfigTest.php +++ b/core/tests/Drupal/KernelTests/Config/TypedConfigTest.php @@ -24,6 +24,11 @@ class TypedConfigTest extends KernelTestBase { */ protected static $modules = ['config_test']; + /** + * {@inheritdoc} + */ + protected static $configSchemaCheckerExclusions = ['config_test.validation']; + /** * {@inheritdoc} */ @@ -86,7 +91,7 @@ public function testTypedDataAPI() { $typed_config_manager = \Drupal::service('config.typed'); $typed_config = $typed_config_manager->createFromNameAndData('config_test.validation', \Drupal::configFactory()->get('config_test.validation')->get()); $this->assertInstanceOf(TypedConfigInterface::class, $typed_config); - $this->assertEquals(['_core', 'llama', 'cat', 'giraffe', 'uuid'], array_keys($typed_config->getElements())); + $this->assertEquals(['_core', 'llama', 'cat', 'giraffe', 'uuid', 'langcode'], array_keys($typed_config->getElements())); $config_test_entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([ 'id' => 'asterix', diff --git a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php deleted file mode 100644 index 483d104c8c..0000000000 --- a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php +++ /dev/null @@ -1,76 +0,0 @@ -register('default_config_test.schema_storage') - ->setClass('\Drupal\config_test\TestInstallStorage') - ->addArgument(InstallStorage::CONFIG_SCHEMA_DIRECTORY); - - $definition = $container->getDefinition('config.typed'); - $definition->replaceArgument(1, new Reference('default_config_test.schema_storage')); - } - - /** - * Tests default configuration data type. - */ - public function testDefaultConfig() { - $typed_config = \Drupal::service('config.typed'); - // Create a configuration storage with access to default configuration in - // every module, profile and theme. - $default_config_storage = new TestInstallStorage(); - foreach ($default_config_storage->listAll() as $config_name) { - if (in_array($config_name, $this->toSkip)) { - continue; - } - - $data = $default_config_storage->read($config_name); - $this->assertConfigSchema($typed_config, $config_name, $data); - } - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php index 97699eeb99..bd89523a54 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php @@ -56,9 +56,14 @@ public function testTrait() { $config_data['boolean'] = []; $ret = $this->checkConfigSchema($this->typedConfig, 'config_test.types', $config_data); $expected = [ + // Storage type check errors. + // @see \Drupal\Core\Config\Schema\SchemaCheckTrait::checkValue() 'config_test.types:new_key' => 'missing schema', 'config_test.types:new_array' => 'missing schema', 'config_test.types:boolean' => 'non-scalar value but not defined as an array (such as mapping or sequence)', + // Validation constraints violations. + // @see \Drupal\Core\TypedData\TypedDataInterface::validate() + '0' => '[boolean] This value should be of the correct primitive type.', ]; $this->assertEquals($expected, $ret); }