function 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

drupal/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php, line 131
Definition of 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 = 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 override 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();
}