diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php new file mode 100644 index 00000000000..db95f06f1b8 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php @@ -0,0 +1,87 @@ + 'System config upgrade test', + 'description' => 'Tests upgrade of system variables to the configuration system.', + 'group' => 'Upgrade path', + ); + } + + public function setUp() { + $this->databaseDumpFiles = array( + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz', + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.system.database.php', + ); + parent::setUp(); + } + + /** + * Tests upgrade of system variables. + */ + public function testSystemVariableUpgrade() { + $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + + // Verify that variables were properly upgraded. + $expected_config['system.cron'] = array( + 'key' => 'kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M', + 'threshold.autorun' => '86400', + 'threshold.requirements_warning' => '86400', + 'threshold.requirements_error' => '172800', + ); + + $expected_config['system.logging'] = array( + 'error_level' => 'some', + ); + + $expected_config['system.maintenance'] = array( + 'enabled' => '1', + 'message' => 'Testing config upgrade', + ); + + $expected_config['system.performance'] = array( + 'cache.page.enabled' => '1', + 'cache.page.max_age' => '1800', + 'response.gzip' => '1', + 'preprocess.js' => '1', + 'preprocess.css' => '1', + ); + + $expected_config['system.rss'] = array( + 'channel.description' => 'Testing config upgrade', + 'items.limit' => '20', + 'items.view_mode' => 'teaser', + ); + + $expected_config['system.site'] = array( + 'name' => 'Testing config upgrade', + // The upgrade from site_mail to system.site:mail is not testable as + // simpletest overrides this configuration with simpletest@example.com. + // 'mail' => 'config@example.com', + 'slogan' => 'CMI makes Drupal 8 drush cex -y', + 'page.403' => '403', + 'page.404' => '404', + 'page.front' => 'node', + ); + + foreach ($expected_config as $file => $values) { + $config = config($file); + $this->verbose(print_r($config->get(), TRUE)); + foreach ($values as $name => $value) { + $stored = $config->get($name); + $this->assertEqual($value, $stored, format_string('Expected value for %name found: %stored (previously: %value).', array('%stored' => $stored, '%name' => $name, '%value' => $value))); + } + } + } +} diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 9f101196df4..4fe99f90182 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1948,7 +1948,7 @@ function system_update_8016() { * @ingroup config_upgrade */ function system_update_8017() { - update_variables_to_config('system.site', array( + update_variables_to_config('system.performance', array( 'cache' => 'cache.page.enabled', 'page_cache_maximum_age' => 'cache.page.max_age', 'page_compression' => 'response.gzip', diff --git a/core/modules/system/tests/upgrade/drupal-7.system.database.php b/core/modules/system/tests/upgrade/drupal-7.system.database.php new file mode 100644 index 00000000000..8afbc12ae84 --- /dev/null +++ b/core/modules/system/tests/upgrade/drupal-7.system.database.php @@ -0,0 +1,104 @@ +fields(array( + 'name', + 'value', +)) +->values(array( + 'name' => 'cache', + 'value'=> 'i:1;', +)) +->values(array( + 'name' => 'cache_lifetime', + 'value' => 's:5:"10800";', + )) +->values(array( + 'name' => 'page_cache_maximum_age', + 'value' => 's:4:"1800";', + )) +->values(array( + 'name' => 'page_compression', + 'value' => 'i:1;', + )) +->values(array( + 'name' => 'preprocess_css', + 'value' => 'i:1;', + )) +->values(array( + 'name' => 'preprocess_js', + 'value' => 'i:1;', + )) +->values(array( + 'name' => 'cron_safe_threshold', + 'value' => 's:5:"86400";', + )) +->values(array( + 'name' => 'cron_threshold_warning', + 'value' => 's:5:"86400";', + )) +->values(array( + 'name' => 'cron_threshold_error', + 'value' => 's:6:"172800";', + )) +->values(array( + 'name' => 'error_level', + 'value' => 's:1:"1";', + )) +->values(array( + 'name' => 'maintenance_mode', + 'value' => 'i:1;', + )) +->values(array( + 'name' => 'maintenance_mode_message', + 'value' => 's:22:"Testing config upgrade"', + )) +->values(array( + 'name' => 'feed_default_items', + 'value' => 's:2:"20";', + )) +->values(array( + 'name' => 'feed_description', + 'value' => 's:22:"Testing config upgrade";', + )) +->values(array( + 'name' => 'feed_item_length', + 'value' => 's:6:"teaser";', + )) +->values(array( + 'name' => 'site_403', + 'value' => 's:3:"403";', + )) +->values(array( + 'name' => 'site_404', + 'value' => 's:3:"404";', + )) +->values(array( + 'name' => 'site_frontpage', + 'value' => 's:4:"node";', + )) +->values(array( + 'name' => 'site_slogan', + 'value' => 's:31:"CMI makes Drupal 8 drush cex -y";', + )) +->execute(); + +db_update('variable') + ->fields(array('value' => 's:18:"config@example.com";')) + ->condition('name', 'site_mail') + ->execute(); +db_update('variable') + ->fields(array('value' => 's:22:"Testing config upgrade";')) + ->condition('name', 'site_name') + ->execute(); +