function ThemeInfoTest::testStylesheets
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php \Drupal\Tests\system\Functional\Theme\ThemeInfoTest::testStylesheets()
- 10 core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php \Drupal\Tests\system\Functional\Theme\ThemeInfoTest::testStylesheets()
- 11.x core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php \Drupal\Tests\system\Functional\Theme\ThemeInfoTest::testStylesheets()
Tests stylesheets-remove.
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ ThemeInfoTest.php, line 61
Class
- ThemeInfoTest
- Tests processing of theme .info.yml properties.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testStylesheets() {
$this->themeInstaller
->install([
'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->assertCount(1, $this->xpath('//link[contains(@href, :href)]', [
':href' => "{$base}/base-add.css",
]), "{$base}/base-add.css found");
$this->assertCount(0, $this->xpath('//link[contains(@href, :href)]', [
':href' => "base-remove.css",
]), "base-remove.css not found");
$this->assertCount(1, $this->xpath('//link[contains(@href, :href)]', [
':href' => "{$sub}/sub-add.css",
]), "{$sub}/sub-add.css found");
$this->assertCount(0, $this->xpath('//link[contains(@href, :href)]', [
':href' => "sub-remove.css",
]), "sub-remove.css not found");
$this->assertCount(0, $this->xpath('//link[contains(@href, :href)]', [
':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->assertCount(1, $this->xpath('//link[contains(@href, :href)]', [
':href' => "{$base}/samename.css",
]), "{$base}/samename.css found");
$this->assertCount(1, $this->xpath('//link[contains(@href, :href)]', [
':href' => "{$sub}/samename.css",
]), "{$sub}/samename.css found");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.