function CascadingStylesheetsTest::testRenderOrder

Tests CSS ordering.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php, line 177
Definition of Drupal\system\Tests\Common\CascadingStylesheetsTest.

Class

CascadingStylesheetsTest
Tests the Drupal CSS system.

Namespace

Drupal\system\Tests\Common

Code

function testRenderOrder() {

  // A module CSS file.
  drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css');

  // A few system CSS files, ordered in a strange way.
  $system_path = drupal_get_path('module', 'system');
  drupal_add_css($system_path . '/system.base.css', array(
    'group' => CSS_SYSTEM,
    'weight' => -10,
  ));
  drupal_add_css($system_path . '/system.theme.css', array(
    'group' => CSS_SYSTEM,
  ));
  $expected = array(
    $system_path . '/system.base.css',
    $system_path . '/system.theme.css',
    drupal_get_path('module', 'simpletest') . '/simpletest.css',
  );
  $styles = drupal_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.');
}