function ColorTestCase::_testColor

Tests the Color module functionality using the given theme.

1 call to ColorTestCase::_testColor()
ColorTestCase::testColor in modules/color/color.test
Tests the Color module functionality.

File

modules/color/color.test, line 71

Class

ColorTestCase
Tests the Color module functionality.

Code

function _testColor($theme, $test_values) {
    variable_set('theme_default', $theme);
    $settings_path = 'admin/appearance/settings/' . $theme;
    $this->drupalLogin($this->big_user);
    $this->drupalGet($settings_path);
    $this->assertResponse(200);
    $edit['scheme'] = '';
    $edit[$test_values['palette_input']] = '#123456';
    $this->drupalPost($settings_path, $edit, t('Save configuration'));
    $this->drupalGet('<front>');
    $stylesheets = variable_get('color_' . $theme . '_stylesheets', array());
    $this->assertPattern('|' . file_create_url($stylesheets[0]) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')');
    $stylesheet_content = join("\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->drupalGet($settings_path);
    $this->assertResponse(200);
    $edit['scheme'] = $test_values['scheme'];
    $this->drupalPost($settings_path, $edit, t('Save configuration'));
    $this->drupalGet('<front>');
    $stylesheets = variable_get('color_' . $theme . '_stylesheets', array());
    $stylesheet_content = join("\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.
    variable_set('preprocess_css', 1);
    $this->drupalGet('<front>');
    $stylesheets = variable_get('drupal_css_cache_files', array());
    $stylesheet_content = '';
    foreach ($stylesheets as $key => $uri) {
        $stylesheet_content .= join("\n", file(drupal_realpath($uri)));
    }
    $this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')');
    variable_set('preprocess_css', 0);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.