function ThemeTest::testCSSOverride
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Theme/ThemeTest.php \Drupal\Tests\system\Functional\Theme\ThemeTest::testCSSOverride()
- 8.9.x core/modules/system/tests/src/Functional/Theme/ThemeTest.php \Drupal\Tests\system\Functional\Theme\ThemeTest::testCSSOverride()
- 11.x core/modules/system/tests/src/Functional/Theme/ThemeTest.php \Drupal\Tests\system\Functional\Theme\ThemeTest::testCSSOverride()
Ensures a theme's .info.yml file is able to override a module CSS file from being added to the page.
See also
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ ThemeTest.php, line 110
Class
- ThemeTest
- Tests low-level theme functions.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testCSSOverride() : void {
// Reuse the same page as in testPreprocessForSuggestions(). We're testing
// what is output to the HTML HEAD based on what is in a theme's .info.yml
// file, so it doesn't matter what page we get, as long as it is themed with
// the test theme. First we test with CSS aggregation disabled.
$config = $this->config('system.performance');
$config->set('css.preprocess', 0);
$config->save();
$this->drupalGet('theme-test/suggestion');
// We add a "?" to the assertion, because drupalSettings may include
// information about the file; we only really care about whether it appears
// in a LINK or STYLE tag, for which Drupal always adds a query string for
// cache control.
$this->assertSession()
->responseNotContains('js.module.css?');
// Also test with aggregation enabled, simply ensuring no PHP errors are
// triggered during drupal_build_css_cache() when a source file doesn't
// exist. Then allow remaining tests to continue with aggregation disabled
// by default.
$config->set('css.preprocess', 1);
$config->save();
$this->drupalGet('theme-test/suggestion');
$config->set('css.preprocess', 0);
$config->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.