You are here

function CascadingStylesheetsUnitTest::testLoadCssBasic in SimpleTest 7

Tests basic CSS loading with and without optimization via drupal_load_stylesheet().

This can be enhanced by adding additional CSS files with variant test cases. Currently, this is specifically testing to make sure that whitespace is treated with adequate respect (not arbitrarily removing linefeeds).

File

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

Class

CascadingStylesheetsUnitTest
CSS Unit Tests.

Code

function testLoadCssBasic() {

  // Array of files to test living in 'simpletest/files/css_test_files/'.
  // - Original: name.css
  // - Unoptimized expected content: name.css.unoptimized.css
  // - Optimized expected content: name.css.optimized.css
  $testfiles = array(
    'css_input_without_import.css',
  );
  $path = drupal_get_path('module', 'simpletest') . '/files/css_test_files';
  foreach ($testfiles as $file) {
    $expected = file_get_contents("{$path}/{$file}.unoptimized.css");
    $unoptimized_output = drupal_load_stylesheet("{$path}/{$file}.unoptimized.css", FALSE);
    $this
      ->assertEqual($unoptimized_output, $expected, t('Unoptimized CSS file has expected contents (@file)', array(
      '@file' => $file,
    )));
    $expected = file_get_contents("{$path}/{$file}.optimized.css");
    $optimized_output = drupal_load_stylesheet("{$path}/{$file}", TRUE);
    $this
      ->assertEqual($optimized_output, $expected, t('Optimized CSS file has expected contents (@file)', array(
      '@file' => $file,
    )));
  }
}