3 namespace Drupal\KernelTests\Core\Config;
5 use Drupal\Tests\SchemaCheckTestTrait;
6 use Drupal\config_test\TestInstallStorage;
7 use Drupal\Core\Config\InstallStorage;
8 use Drupal\Core\DependencyInjection\ContainerBuilder;
9 use Drupal\KernelTests\KernelTestBase;
10 use Symfony\Component\DependencyInjection\Reference;
13 * Tests that default configuration provided by all modules matches schema.
17 class DefaultConfigTest extends KernelTestBase {
19 use SchemaCheckTestTrait;
26 public static $modules = ['system', 'config_test'];
29 * Themes which provide default configuration and need enabling.
31 * If a theme provides default configuration but does not have a schema
32 * because it can rely on schemas added by system_config_schema_info_alter()
33 * then this test needs to enable it.
37 protected $themes = ['seven'];
39 protected function setUp() {
41 \Drupal::service('theme_handler')->install($this->themes);
47 public function register(ContainerBuilder $container) {
48 parent::register($container);
49 $container->register('default_config_test.schema_storage')
50 ->setClass('\Drupal\config_test\TestInstallStorage')
51 ->addArgument(InstallStorage::CONFIG_SCHEMA_DIRECTORY);
53 $definition = $container->getDefinition('config.typed');
54 $definition->replaceArgument(1, new Reference('default_config_test.schema_storage'));
58 * Tests default configuration data type.
60 public function testDefaultConfig() {
61 $typed_config = \Drupal::service('config.typed');
62 // Create a configuration storage with access to default configuration in
63 // every module, profile and theme.
64 $default_config_storage = new TestInstallStorage();
66 foreach ($default_config_storage->listAll() as $config_name) {
67 // Skip files provided by the config_schema_test module since that module
68 // is explicitly for testing schema.
69 if (strpos($config_name, 'config_schema_test') === 0) {
73 $data = $default_config_storage->read($config_name);
74 $this->assertConfigSchema($typed_config, $config_name, $data);