1 color.test | public ColorTestCase::testColor() |
Tests the Color module functionality.
File
- core/
modules/ color/ tests/ color.test, line 57 - Tests for color module.
Class
- ColorTestCase
- Tests the Color module functionality.
Code
public function testColor() {
foreach ($this->themes as $theme => $test_values) {
config_set('system.core', 'theme_default', $theme);
$settings_path = 'admin/appearance/settings/' . $theme;
$this->backdropLogin($this->bigUser);
$this->backdropGet($settings_path);
$this->assertResponse(200);
$edit['scheme'] = '';
$edit[$test_values['palette_input']] = '#123456';
$this->backdropPost($settings_path, $edit, t('Save theme settings'));
$this->backdropGet('<front>');
$stylesheets = theme_get_setting('color.stylesheets', $theme);
$this->assertPattern('|' . file_create_url($stylesheets[0]) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')');
$stylesheet_content = implode("\n", file($stylesheets[0]));
$this->assertTrue(strpos($stylesheet_content, 'color: #123456') !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')');
$this->backdropGet($settings_path);
$this->assertResponse(200);
$edit['scheme'] = $test_values['scheme'];
$this->backdropPost($settings_path, $edit, t('Save theme settings'));
$this->backdropGet('<front>');
backdrop_static_reset();
$stylesheets = theme_get_setting('color.stylesheets', $theme);
$stylesheet_content = implode("\n", file($stylesheets[0]));
$this->assertTrue(strpos($stylesheet_content, 'color: ' . $test_values['scheme_color']) !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')');
// Test with aggregated CSS turned on.
config_set('system.core', 'preprocess_css', 1);
$this->backdropGet('<front>');
$stylesheets = state_get('css_cache_files', array());
$stylesheet_content = '';
foreach ($stylesheets as $key => $uri) {
$stylesheet_content .= implode("\n", file(backdrop_realpath($uri)));
}
$this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')');
config_set('system.core', 'preprocess_css', 0);
}
}