You are here

function ThemeTest::testCSSOverride in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/ThemeTest.php \Drupal\system\Tests\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

test_theme.info.yml

File

core/modules/system/src/Tests/Theme/ThemeTest.php, line 169
Contains \Drupal\system\Tests\Theme\ThemeTest.

Class

ThemeTest
Tests low-level theme functions.

Namespace

Drupal\system\Tests\Theme

Code

function testCSSOverride() {

  // 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');
  $this
    ->assertNoText('system.module.css', "The theme's .info.yml file is able to remove a module CSS file from being added to the page.");

  // 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();
}