Issue #1789606 by sun, alexpott: Fixed Upgrade path tests for all system module variables converted to CMI so far.

8.0.x
webchick 2012-09-20 17:45:16 -07:00
parent 5719e7e7d6
commit 7b8712b1b2
3 changed files with 192 additions and 1 deletions

View File

@ -0,0 +1,87 @@
<?php
/**
* @file
* Definition of Drupal\system\Tests\Upgrade\SystemUpgradePathTest.
*/
namespace Drupal\system\Tests\Upgrade;
/**
* Tests upgrade of system variables.
*/
class SystemUpgradePathTest extends UpgradePathTestBase {
public static function getInfo() {
return array(
'name' => '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)));
}
}
}
}

View File

@ -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',

View File

@ -0,0 +1,104 @@
<?php
/**
* @file
* Database additions for system tests. Used in upgrade.system.test.
*
* This dump only contains data and schema components relevant for system
* functionality. The drupal-7.filled.bare.php file is imported before
* this dump, so the two form the database structure expected in tests
* altogether.
*/
// Add non-default system settings.
db_insert('variable')->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();