DefaultConfigTest.php in Zircon Profile 8
File
core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
View source
<?php
namespace Drupal\KernelTests\Config;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\KernelTests\AssertConfigTrait;
use Drupal\KernelTests\KernelTestBase;
class DefaultConfigTest extends KernelTestBase {
use AssertConfigTrait;
protected static $timeLimit = 500;
public static $modules = [
'system',
'user',
];
protected function setUp() {
parent::setUp();
include_once $this->root . '/core/modules/system/system.module';
system_rebuild_module_data();
$this
->installSchema('system', 'router');
}
public function testModuleConfig($module) {
$module_installer = $this->container
->get('module_installer');
$active_config_storage = $this->container
->get('config.storage');
$config_manager = $this->container
->get('config.manager');
$module_installer
->install([
$module,
]);
switch ($module) {
case 'system':
case 'user':
$this
->installConfig([
$module,
]);
break;
}
$default_install_path = drupal_get_path('module', $module) . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
$module_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
$skipped_config = [];
$skipped_config['locale.settings'][] = 'path: ';
$skipped_config['syslog.settings'][] = 'facility: ';
$skipped_config['simpletest.settings'] = TRUE;
foreach ($module_config_storage
->listAll() as $config_name) {
$result = $config_manager
->diff($module_config_storage, $active_config_storage, $config_name);
$this
->assertConfigDiff($result, $config_name, $skipped_config);
}
}
public function providerTestModuleConfig() {
$module_dirs = array_keys(iterator_to_array(new \FilesystemIterator(__DIR__ . '/../../../../modules/')));
$module_names = array_map(function ($path) {
return str_replace(__DIR__ . '/../../../../modules/', '', $path);
}, $module_dirs);
$modules_keyed = array_combine($module_names, $module_names);
$data = array_map(function ($module) {
return [
$module,
];
}, $modules_keyed);
return $data;
}
}