1 color.test public ColorTestCase::testUpdateCssFilesOnConfigSave()

Test if the CSS files for a theme are updated when editing Configuration.

File

core/modules/color/tests/color.test, line 127
Tests for color module.

Class

ColorTestCase
Tests the Color module functionality.

Code

public function testUpdateCssFilesOnConfigSave() {
  config_set('system.core', 'theme_default', 'bartik');
  $settings_path = 'admin/appearance/settings/bartik';
  $import_path = 'admin/config/development/configuration/single';

  // Make sure the theme settings exist by submitting the theme settings form.
  $this->backdropLogin($this->bigUser);
  $this->backdropGet($settings_path);
  $this->assertResponse(200);
  $edit = array(
    'scheme' => '',
    'palette[top]' => '#123456',
  );
  $this->backdropPost($settings_path, $edit, t('Save theme settings'));

  // Edit the theme configuration.
  $this->backdropGet($import_path);
  $config = config('bartik.settings');
  $data = array_merge(array('_config_name' => 'bartik.settings'), $config->get());
  $data['color']['palette']['top'] = '#654321';
  $edit = array('import' => json_encode($data));
  $this->backdropPost($import_path, $edit, t('Import'));

  // Check that the new color shows up in the css files.
  $stylesheets = theme_get_setting('color.stylesheets', 'bartik');
  $stylesheet_content = '';
  foreach ($stylesheets as $stylesheet) {
    $stylesheet_content .= implode("\n", file($stylesheet));
  }
  $this->assertTrue(strpos($stylesheet_content, 'color: #654321') !== FALSE, 'Make sure the color we changed is in the color stylesheet.');
}