public function SystemUpgradePathTest::testVariableUpgrade

Tests upgrade of variables to config.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php, line 33
Definition of Drupal\system\Tests\Upgrade\SystemUpgradePathTest.

Class

SystemUpgradePathTest
Tests upgrade of system variables.

Namespace

Drupal\system\Tests\Upgrade

Code

public function testVariableUpgrade() {
  $this
    ->assertTrue($this
    ->performUpgrade(), 'The upgrade was completed successfully.');

  // Verify that variables were properly upgraded.
  $expected_config['system.cron'] = array(
    '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',
    'js.preprocess' => '1',
    'css.preprocess' => '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',
  );
  $expected_config['user.settings'] = array(
    'cancel_method' => 'user_cancel_reassign',
  );
  $expected_config['system.filter'] = array(
    'protocols.0' => 'http',
    'protocols.1' => 'https',
    'protocols.2' => 'ftp',
    'protocols.3' => 'mailto',
  );
  $expected_config['filter.settings'] = array(
    'fallback_format' => 'plain_text',
  );
  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,
      )));
    }
  }
}