You are here

function CascadingStylesheetsTestCase::testRenderOrder in SimpleTest 7

Test CSS ordering.

File

tests/common.test, line 578
Tests for common.inc functionality.

Class

CascadingStylesheetsTestCase
Test the Drupal CSS system.

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 . '/defaults.css', array(
    'weight' => CSS_SYSTEM,
  ));
  drupal_add_css($system_path . '/system.css', array(
    'weight' => CSS_SYSTEM - 10,
  ));
  drupal_add_css($system_path . '/system-menus.css', array(
    'weight' => CSS_SYSTEM,
  ));
  $expected = array(
    $system_path . '/system.css',
    $system_path . '/defaults.css',
    $system_path . '/system-menus.css',
    drupal_get_path('module', 'simpletest') . '/simpletest.css',
  );
  $styles = drupal_get_css();
  if (preg_match_all('/href="' . preg_quote($GLOBALS['base_url'] . '/', '/') . '([^?]+)\\?/', $styles, $matches)) {
    $result = $matches[1];
  }
  else {
    $result = array();
  }
  $this
    ->assertIdentical($result, $expected, t('The CSS files are in the expected order.'));
}