From df2cf40d2cd197ed5f1960b026b31aad32b5d930 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 26 Oct 2008 18:06:39 +0000 Subject: - Patch #266358 by Rob Loach, mfer: use array in drupal_add_css(). --- modules/simpletest/simpletest.module | 2 +- modules/simpletest/tests/common.test | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'modules/simpletest') diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module index 372ad1f3f..c1752b84f 100644 --- a/modules/simpletest/simpletest.module +++ b/modules/simpletest/simpletest.module @@ -199,7 +199,7 @@ function simpletest_test_form() { } function theme_simpletest_test_table($table) { - drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css', 'module'); + drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css'); drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', 'module'); // Create header for test selection table. diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 74e053cf9..6a82018db 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -114,6 +114,56 @@ class DrupalTagsHandlingTestCase extends DrupalWebTestCase { } } +/** + * Test the Drupal CSS system. + */ +class CascadingStylesheetsTestCase extends DrupalWebTestCase { + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('Cascading stylesheets'), + 'description' => t('Tests adding various cascading stylesheets to the page.'), + 'group' => t('System') + ); + } + + /** + * Implementation of setUp(). + */ + function setUp() { + parent::setUp(); + // Reset drupal_add_css() before each test. + drupal_add_css(NULL, NULL, TRUE); + } + + /** + * Check default stylesheets as empty. + */ + function testDefault() { + $this->assertEqual(array(), drupal_add_css(), t('Default CSS is empty.')); + } + + /** + * Tests adding a file stylesheet. + */ + function testAddFile() { + $path = drupal_get_path('module', 'simpletest') . '/simpletest.css'; + $css = drupal_add_css($path); + $this->assertEqual($css['all']['module'][$path], TRUE, t('Adding a CSS file caches it properly.')); + } + + /** + * Tests rendering the stylesheets. + */ + function testRenderFile() { + $css = drupal_get_path('module', 'simpletest') . '/simpletest.css'; + drupal_add_css($css); + $this->assertTrue(strpos(drupal_get_css(), $css) > 0, t('Rendered CSS includes the added stylesheet.')); + } +} + /** * Test drupal_http_request(). */ -- cgit v1.2.3