You are here

function ThemeInfoTest::testStylesheets in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/ThemeInfoTest.php \Drupal\system\Tests\Theme\ThemeInfoTest::testStylesheets()

Tests stylesheets-remove.

File

core/modules/system/src/Tests/Theme/ThemeInfoTest.php, line 61
Contains \Drupal\system\Tests\Theme\ThemeInfoTest.

Class

ThemeInfoTest
Tests processing of theme .info.yml properties.

Namespace

Drupal\system\Tests\Theme

Code

function testStylesheets() {
  $this->themeHandler
    ->install(array(
    'test_basetheme',
    'test_subtheme',
  ));
  $this
    ->config('system.theme')
    ->set('default', 'test_subtheme')
    ->save();
  $base = drupal_get_path('theme', 'test_basetheme');
  $sub = drupal_get_path('theme', 'test_subtheme') . '/css';

  // All removals are expected to be based on a file's path and name and
  // should work nevertheless.
  $this
    ->drupalGet('theme-test/info/stylesheets');
  $this
    ->assertIdentical(1, count($this
    ->xpath('//link[contains(@href, :href)]', array(
    ':href' => "{$base}/base-add.css",
  ))), "{$base}/base-add.css found");
  $this
    ->assertIdentical(0, count($this
    ->xpath('//link[contains(@href, :href)]', array(
    ':href' => "base-remove.css",
  ))), "base-remove.css not found");
  $this
    ->assertIdentical(1, count($this
    ->xpath('//link[contains(@href, :href)]', array(
    ':href' => "{$sub}/sub-add.css",
  ))), "{$sub}/sub-add.css found");
  $this
    ->assertIdentical(0, count($this
    ->xpath('//link[contains(@href, :href)]', array(
    ':href' => "sub-remove.css",
  ))), "sub-remove.css not found");
  $this
    ->assertIdentical(0, count($this
    ->xpath('//link[contains(@href, :href)]', array(
    ':href' => "base-add.sub-remove.css",
  ))), "base-add.sub-remove.css not found");

  // Verify that CSS files with the same name are loaded from both the base theme and subtheme.
  $this
    ->assertIdentical(1, count($this
    ->xpath('//link[contains(@href, :href)]', array(
    ':href' => "{$base}/samename.css",
  ))), "{$base}/samename.css found");
  $this
    ->assertIdentical(1, count($this
    ->xpath('//link[contains(@href, :href)]', array(
    ':href' => "{$sub}/samename.css",
  ))), "{$sub}/samename.css found");
}