Asserts that the default configuration of a module has been installed.
string $module: The name of the module.
bool TRUE if configuration has been installed, FALSE otherwise.
function assertModuleConfig($module) {
$module_config_dir = drupal_get_path('module', $module) . '/config';
if (!is_dir($module_config_dir)) {
return;
}
$module_file_storage = new FileStorage($module_config_dir);
// Verify that the module's default config directory is not empty and
// contains default configuration files (instead of something else).
$all_names = $module_file_storage
->listAll();
if (empty($all_names)) {
// Module has an empty config directory. For example it might contain a
// schema directory.
return;
}
$this
->assertTrue($all_names);
// Look up each default configuration object name in the active
// configuration, and if it exists, remove it from the stack.
// Only default config that belongs to $module is guaranteed to exist; any
// other default config depends on whether other modules are enabled. Thus,
// list all default config once more, but filtered by $module.
$names = $module_file_storage
->listAll($module . '.');
foreach ($names as $key => $name) {
if (config($name)
->get()) {
unset($names[$key]);
}
}
// Verify that all configuration has been installed (which means that $names
// is empty).
return $this
->assertFalse($names, format_string('All default configuration of @module module found.', array(
'@module' => $module,
)));
}