diff --git a/core/includes/config.inc b/core/includes/config.inc index eb9dcce..8d37e13 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -43,7 +43,6 @@ function config_install_default_config($module) { if (is_dir($module_config_dir)) { $database_storage = new DatabaseStorage(); $module_file_storage = new FileStorage(array('directory' => $module_config_dir)); - $file_storage = new FileStorage(); $files = glob($module_config_dir . '/*.' . FileStorage::getFileExtension()); foreach ($files as $key => $file) { @@ -54,8 +53,6 @@ function config_install_default_config($module) { $data = $module_file_storage->read($config_name); $database_storage->write($config_name, $data); - // @todo Only explicit exports are supposed to write to FileStorage. - $file_storage->write($config_name, $data); } } } diff --git a/core/includes/install.inc b/core/includes/install.inc index 49bc272..67ca802 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -1,7 +1,7 @@ delete($config_name); - } + // Remove all configuration belonging to the module. + $config_names = DatabaseStorage::getNamesWithPrefix($module . '.'); + foreach ($config_names as $config_name) { + config($config_name)->delete(); } watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php index 36ab251..42fcfb6 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php @@ -62,7 +62,7 @@ class ConfigFileContentTest extends WebTestBase { $config = config($name); // Verify an configuration object is returned. -// $this->assertEqual($config->name, $name); + $this->assertEqual($config->getName(), $name); $this->assertTrue($config, t('Config object created.')); // Verify the configuration object is empty. diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php deleted file mode 100644 index ae80fb2..0000000 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php +++ /dev/null @@ -1,48 +0,0 @@ - 'Good morning, Denver!'); - - public static function getInfo() { - return array( - 'name' => 'File security', - 'description' => 'Tests security of saved configuration files.', - 'group' => 'Configuration', - ); - } - - /** - * Tests that a file written by this system can be successfully read back. - */ - function testFilePersist() { - $file = new FileStorage(); - $file->write($this->filename, $this->testContent); - - // Reading should throw an exception in case of bad validation. - // Note that if any other exception is thrown, we let the test system - // handle catching and reporting it. - try { - $saved_content = $file->read($this->filename); - - $this->assertEqual($saved_content, $this->testContent); - } - catch (Exception $e) { - $this->fail('File failed verification when being read.'); - } - } -} diff --git a/core/modules/system/system.test b/core/modules/system/system.test index 17b96c8..80cde8b 100644 --- a/core/modules/system/system.test +++ b/core/modules/system/system.test @@ -1,6 +1,7 @@ assertTrue($files); - $config_dir = config_get_config_directory(); - // Get the filename of each config file. - foreach ($files as $file) { - $parts = explode('/', $file); - $filename = array_pop($parts); - if (!file_exists($config_dir . '/' . $filename)) { - $files_exist = FALSE; - } - } + if (!is_dir($module_config_dir)) { + return; } + $files = glob($module_config_dir . '/*.' . FileStorage::getFileExtension()); + + // Verify that the config directory is not empty. + $this->assertTrue($files); - return $this->assertTrue($files_exist, t('All config files defined by the @module module have been copied to the live config directory.', array('@module' => $module))); + // Check whether each default configuration object exists in the active + // store, and if so, remove it from the stack. + foreach ($files as $key => $file) { + $name = basename($file, '.' . FileStorage::getFileExtension()); + if (config($name)->get()) { + unset($files[$key]); + } + } + // Verify that all configuration has been installed (which means that $files + // is empty). + return $this->assertFalse($files, format_string('Default configuration of @module module found.', array('@module' => $module))); } /** - * Assert that none of a module's default config files are loaded. + * Asserts that no configuration exists for a given module. * * @param string $module * The name of the module. * * @return bool - * TRUE if the module's config files do not exist, FALSE otherwise. + * TRUE if no configuration was found, FALSE otherwise. */ - function assertModuleConfigFilesDoNotExist($module) { - // Define test variable. - $files_exist = FALSE; - // Get the path to the module's config dir. - $module_config_dir = drupal_get_path('module', $module) . '/config'; - if (is_dir($module_config_dir)) { - $files = glob($module_config_dir . '/*.' . FileStorage::getFileExtension()); - $this->assertTrue($files); - $config_dir = config_get_config_directory(); - // Get the filename of each config file. - foreach ($files as $file) { - $parts = explode('/', $file); - $filename = array_pop($parts); - if (file_exists($config_dir . '/' . $filename)) { - $files_exist = TRUE; - } - } - } - - return $this->assertFalse($files_exist, t('All config files defined by the @module module have been deleted from the live config directory.', array('@module' => $module))); + function assertNoModuleConfig($module) { + $names = DatabaseStorage::getNamesWithPrefix($module . '.'); + return $this->assertFalse($names, format_string('No configuration found for @module module.', array('@module' => $module))); } /** @@ -293,7 +278,7 @@ class EnableDisableTestCase extends ModuleTestCase { $this->assertText(t('hook_modules_enabled fired for @module', array('@module' => $module_to_enable))); $this->assertModules(array($module_to_enable), TRUE); $this->assertModuleTablesExist($module_to_enable); - $this->assertModuleConfigFilesExist($module_to_enable); + $this->assertModuleConfig($module_to_enable); $this->assertLogMessage('system', "%module module installed.", array('%module' => $module_to_enable), WATCHDOG_INFO); $this->assertLogMessage('system', "%module module enabled.", array('%module' => $module_to_enable), WATCHDOG_INFO); } @@ -374,7 +359,7 @@ class EnableDisableTestCase extends ModuleTestCase { // Check that the module's database tables still exist. $this->assertModuleTablesExist($module); // Check that the module's config files still exist. - $this->assertModuleConfigFilesExist($module); + $this->assertModuleConfig($module); // Uninstall the module. $edit = array(); @@ -396,7 +381,7 @@ class EnableDisableTestCase extends ModuleTestCase { // Check that the module's database tables no longer exist. $this->assertModuleTablesDoNotExist($module); // Check that the module's config files no longer exist. - $this->assertModuleConfigFilesDoNotExist($module); + $this->assertNoModuleConfig($module); } }