DefaultConfigTest.php in Drupal 9
File
core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Config;
use Drupal\Tests\SchemaCheckTestTrait;
use Drupal\config_test\TestInstallStorage;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\DependencyInjection\Reference;
class DefaultConfigTest extends KernelTestBase {
use SchemaCheckTestTrait;
protected static $modules = [
'system',
'config_test',
];
protected $toSkip = [
'config_schema_test.ignore',
'config_schema_test.noschema',
'config_schema_test.plugin_types',
'config_schema_test.someschema.somemodule.section_one.subsection',
'config_schema_test.someschema.somemodule.section_two.subsection',
'config_schema_test.someschema.with_parents',
'config_schema_test.someschema',
'tour.tour.tour-test-legacy',
'tour.tour.tour-test-legacy-location',
];
protected $themes = [
'seven',
];
protected function setUp() : void {
parent::setUp();
\Drupal::service('theme_installer')
->install($this->themes);
}
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);
$definition = $container
->getDefinition('config.typed');
$definition
->replaceArgument(1, new Reference('default_config_test.schema_storage'));
}
public function testDefaultConfig() {
$typed_config = \Drupal::service('config.typed');
$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);
}
}
}
Classes
Name |
Description |
DefaultConfigTest |
Tests that default configuration provided by all modules matches schema. |