ThemeInfoStylesTest.php 1.7 KB
Newer Older
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
<?php

/**
 * @file
 * Contains Drupal\system\Tests\Theme\ThemeInfoStylesTest.
 */

namespace Drupal\system\Tests\Theme;

use Drupal\simpletest\WebTestBase;

/**
 * Tests processing of theme .info stylesheets.
 */
class ThemeInfoStylesTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('theme_test');

  public static function getInfo() {
    return array(
      'name' => 'Theme .info styles',
      'description' => 'Tests processing of theme .info stylesheets.',
      'group' => 'Theme',
    );
  }

  /**
   * Tests stylesheets-override and stylesheets-remove.
   */
  function testStylesheets() {
    theme_enable(array('test_basetheme', 'test_subtheme'));
37 38 39
    config('system.theme')
      ->set('default', 'test_subtheme')
      ->save();
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

    $base = drupal_get_path('theme', 'test_basetheme');
    // Unlike test_basetheme (and the original module CSS), the subtheme decides
    // to put all of its CSS into a ./css subdirectory. All overrides and
    // removals are expected to be based on a file's basename and should work
    // nevertheless.
    $sub = drupal_get_path('theme', 'test_subtheme') . '/css';

    $this->drupalGet('theme-test/info/stylesheets');

    $this->assertRaw("$base/base-add.css");
    $this->assertRaw("$base/base-override.css");
    $this->assertNoRaw("base-remove.css");

    $this->assertRaw("$sub/sub-add.css");

    $this->assertRaw("$sub/sub-override.css");
    $this->assertRaw("$sub/base-add.sub-override.css");
    $this->assertRaw("$sub/base-remove.sub-override.css");

    $this->assertNoRaw("sub-remove.css");
    $this->assertNoRaw("base-add.sub-remove.css");
    $this->assertNoRaw("base-override.sub-remove.css");
  }
}