1 common.test CommonCascadingStylesheetsTestCase::testRenderOrder()

Test CSS ordering.

File

core/modules/simpletest/tests/common.test, line 851
Tests for common.inc functionality.

Class

CommonCascadingStylesheetsTestCase
Test the Backdrop CSS system.

Code

function testRenderOrder() {
  // A module CSS file.
  backdrop_add_css(backdrop_get_path('module', 'simpletest') . '/css/simpletest.css');
  // A few system CSS files, ordered in a strange way.
  $system_path = backdrop_get_path('module', 'system');
  backdrop_add_css($system_path . '/css/system.css', array('group' => CSS_SYSTEM, 'weight' => -10));
  backdrop_add_css($system_path . '/css/system.theme.css', array('group' => CSS_SYSTEM));

  $expected = array(
    $system_path . '/css/system.css',
    $system_path . '/css/system.theme.css',
    backdrop_get_path('module', 'simpletest') . '/css/simpletest.css',
  );

  $styles = backdrop_get_css();
  // Stylesheet URL may be the href of a LINK tag or in an @import statement
  // of a STYLE tag.
  if (preg_match_all('/(href="|url\(")' . preg_quote($GLOBALS['base_url'] . '/', '/') . '([^?]+)\?/', $styles, $matches)) {
    $result = $matches[2];
  }
  else {
    $result = array();
  }

  $this->assertIdentical($result, $expected, 'The CSS files are in the expected order.');
}