summaryrefslogtreecommitdiff
path: root/modules/color/color.test
blob: dff4e6d729e40d3173c00ef3db974f5dc7f1beab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
// $Id$

/**
 * @file
 * Tests for color module.
 */

/**
 * Test color functionality.
 */
class ColorTestCase extends DrupalWebTestCase {
  protected $big_user;

  public static function getInfo() {
    return array(
      'name' => 'Color functionality',
      'description' => 'Modify the garland theme color and make sure the changes are reflected on the frontend',
      'group' => 'Color',
    );
  }

  function setUp() {
    parent::setUp('color');

    // Create users.
    $this->big_user = $this->drupalCreateUser(array('administer themes'));

    // This test relies on Garland, the mother of all the colorable themes.
    theme_enable(array('garland'));
    variable_set('theme_default', 'garland');
  }

  /**
   * Test color module functionality.
   */
  function testColor() {
    $this->drupalLogin($this->big_user);
    $this->drupalGet('admin/appearance/settings/garland');
    $this->assertResponse(200);
    $edit['scheme'] = '';
    $edit['palette[link]'] = '#123456';
    $this->drupalPost('admin/appearance/settings/garland', $edit, t('Save configuration'));

    $this->drupalGet('<front>');
    $stylesheets = variable_get('color_garland_stylesheets', array());
    $this->assertPattern('|' . file_create_url($stylesheets[0]) . '|', 'Make sure the color stylesheet is included in the content.');

    $stylesheet_content = join("\n", file($stylesheets[0]));
    $matched = preg_match('/(.*color: #123456.*)/i', $stylesheet_content, $matches);
    $this->assertTrue($matched == 1, 'Make sure the color we changed is in the color stylesheet.');

    $this->drupalGet('admin/appearance/settings/garland');
    $this->assertResponse(200);
    $edit['scheme'] = 'greenbeam';
    $this->drupalPost('admin/appearance/settings/garland', $edit, t('Save configuration'));

    $this->drupalGet('<front>');
    $stylesheets = variable_get('color_garland_stylesheets', array());
    $stylesheet_content = join("\n", file($stylesheets[0]));
    $matched = preg_match('/(.*color: #0c7a00.*)/i', $stylesheet_content, $matches);
    $this->assertTrue($matched == 1, 'Make sure the color we changed is in the color stylesheet.');
  }

}