diff --git a/core/modules/config/tests/src/Kernel/ConfigImportRecreateTest.php b/core/modules/config/tests/src/Kernel/ConfigImportRecreateTest.php index 86a7ac7..51b22cd 100644 --- a/core/modules/config/tests/src/Kernel/ConfigImportRecreateTest.php +++ b/core/modules/config/tests/src/Kernel/ConfigImportRecreateTest.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\StorageComparer; +use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\NodeType; /** diff --git a/core/modules/config/tests/src/Kernel/ConfigImporterTest.php b/core/modules/config/tests/src/Kernel/ConfigImporterTest.php index a4c3c14..04a3a7f 100644 --- a/core/modules/config/tests/src/Kernel/ConfigImporterTest.php +++ b/core/modules/config/tests/src/Kernel/ConfigImporterTest.php @@ -677,8 +677,9 @@ public function testInstallProfile() { * Tests config_get_config_directory(). */ public function testConfigGetConfigDirectory() { + global $config_directories; $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); - $this->assertEqual($this->configDirectories[CONFIG_SYNC_DIRECTORY], $directory); + $this->assertEqual($config_directories[CONFIG_SYNC_DIRECTORY], $directory); $message = 'Calling config_get_config_directory() with CONFIG_ACTIVE_DIRECTORY results in an exception.'; try { diff --git a/core/modules/config/tests/src/Kernel/ConfigSchemaTest.php b/core/modules/config/tests/src/Kernel/ConfigSchemaTest.php index 3b0504e..7074a97 100644 --- a/core/modules/config/tests/src/Kernel/ConfigSchemaTest.php +++ b/core/modules/config/tests/src/Kernel/ConfigSchemaTest.php @@ -388,7 +388,7 @@ public function testConfigSaveWithSchema() { // Ensure that configuration objects with keys marked as ignored are not // changed when saved. The 'config_schema_test.ignore' will have been saved // during the installation of configuration in the setUp method. - $extension_path = __DIR__ . '/../../tests/config_schema_test/'; + $extension_path = __DIR__ . '/../../config_schema_test/'; $install_storage = new FileStorage($extension_path . InstallStorage::CONFIG_INSTALL_DIRECTORY); $original_data = $install_storage->read('config_schema_test.ignore'); $installed_data = $this->config('config_schema_test.ignore')->get(); diff --git a/core/modules/config/tests/src/Kernel/DefaultConfigTest.php b/core/modules/config/tests/src/Kernel/DefaultConfigTest.php index 3e72d70..7bbc6b4 100644 --- a/core/modules/config/tests/src/Kernel/DefaultConfigTest.php +++ b/core/modules/config/tests/src/Kernel/DefaultConfigTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\config\Kernel; +use Drupal\config\Tests\SchemaCheckTestTrait; use Drupal\config_test\TestInstallStorage; use Drupal\Core\Config\InstallStorage; use Drupal\Core\DependencyInjection\ContainerBuilder; @@ -23,15 +24,6 @@ class DefaultConfigTest extends KernelTestBase { use SchemaCheckTestTrait; /** - * Modules to enable. - * - * Enable the system module so that system_config_schema_info_alter() fires. - * - * @var array - */ - public static $modules = array('system', 'config_test'); - - /** * Themes which provide default configuration and need enabling. * * If a theme provides default configuration but does not have a schema @@ -50,8 +42,8 @@ protected function setUp() { /** * {@inheritdoc} */ - public function containerBuild(ContainerBuilder $container) { - parent::containerBuild($container); + public function register(ContainerBuilder $container) { + parent::register($container); $container->register('default_config_test.schema_storage') ->setClass('\Drupal\config_test\TestInstallStorage') ->addArgument(InstallStorage::CONFIG_SCHEMA_DIRECTORY); diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index d20f341..68b618e 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -192,6 +192,22 @@ protected $strictConfigSchema = TRUE; /** + * An array of config object names that are excluded from schema checking. + * + * @var string[] + */ + protected static $configSchemaCheckerExclusions = 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', + ); + + /** * {@inheritdoc} */ public static function setUpBeforeClass() { @@ -578,6 +594,7 @@ public function register(ContainerBuilder $container) { $container ->register('simpletest.config_schema_checker', 'Drupal\Core\Config\Testing\ConfigSchemaChecker') ->addArgument(new Reference('config.typed')) + ->addArgument($this->getConfigSchemaExclusions()) ->addTag('event_subscriber'); } @@ -598,6 +615,25 @@ public function register(ContainerBuilder $container) { } /** + * Gets the config schema exclusions for this test. + * + * @return string[] + * An array of config object names that are excluded from schema checking. + */ + protected function getConfigSchemaExclusions() { + $class = get_class($this); + $exceptions = []; + while ($class) { + if (property_exists($class, 'configSchemaCheckerExclusions')) { + $exceptions = array_merge($exceptions, $class::$configSchemaCheckerExclusions); + } + $class = get_parent_class($class); + } + // Filter out any duplicates. + return array_unique($exceptions); + } + + /** * {@inheritdoc} */ protected function assertPostConditions() {