1 color.test public ColorTestCase::testBartikLegacy()

Test the Bartik legacy color mode.

File

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

Class

ColorTestCase
Tests the Color module functionality.

Code

public function testBartikLegacy() {
  config_set('system.core', 'theme_default', 'bartik');
  $settings_path = 'admin/appearance/settings/bartik';

  $info = array();
  include BACKDROP_ROOT . '/' . backdrop_get_path('theme', 'bartik') . '/color/color.inc';

  $default_palette = $info['schemes']['default']['colors'];
  $blue_lagoon_palette = $info['schemes']['blue_lagoon']['colors'];

  // Set the colors to the Blue Lagoon palette.
  $edit = array();
  foreach ($blue_lagoon_palette as $key => $color) {
    $edit["palette[$key]"] = $color;
  }
  $this->backdropLogin($this->bigUser);
  $this->backdropPost($settings_path, $edit, t('Save theme settings'));

  // No color settings should be saved other than the legacy option.
  $this->assertTrue(config_get('bartik.settings', 'color_legacy'), 'Legacy color flag set in Bartik configuration.');
  $this->assertNull(config_get('bartik.settings', 'color'), 'No other color settings saved.');
  $this->backdropGet('');
  $this->assertRaw('bartik/css/colors-legacy.css', 'Legacy color CSS found on the homepage.');
  $this->assertNoRaw('bartik/css/legacy.css', 'Default color CSS correctly not used on the homepage.');

  // Modify the palette to trigger a custom palette.
  $edit['palette[top]'] = '#292929';
  $this->backdropPost($settings_path, $edit, t('Save theme settings'));

  // Now neither the original nor legacy CSS file should be used.
  $this->assertFalse(config_get('bartik.settings', 'color_legacy'), 'Legacy color flag set to FALSE in Bartik configuration.');
  $this->backdropGet('');
  $this->assertNoRaw('bartik/css/colors-legacy.css', 'Legacy color CSS correctly not found found on the homepage.');
  $this->assertNoRaw('bartik/css/colors.css', 'Default color CSS correctly not used on the homepage.');

  // Set back to the default palette.
  $edit = array(
    'scheme' => 'default',
  );
  foreach ($default_palette as $key => $color) {
    $edit["palette[$key]"] = $color;
  }
  $this->backdropPost($settings_path, $edit, t('Save theme settings'));
  $this->assertFalse(config_get('bartik.settings', 'color_legacy'), 'Legacy color flag set to FALSE in Bartik configuration.');
  $this->assertNull(config_get('bartik.settings', 'color'), 'Color settings emptied out.');
  $this->assertNoRaw('bartik/css/colors-legacy.css', 'Legacy color CSS correctly not found found on the homepage.');
  $this->assertRaw('bartik/css/colors.css', 'Default color CSS found on the homepage.');
}