From a0cca9a472b7764f54ad692c8e7943278f09a0be Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Mon, 30 Mar 2009 05:13:45 +0000 Subject: #259368 by Rob Loach, mfer, and sun: Allow drupal_add_css() to add/aggregate inline CSS. --- modules/simpletest/tests/common.test | 46 ++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 0f3fd2cbb..2fa9b1687 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -188,12 +188,12 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { return array( 'name' => t('Cascading stylesheets'), 'description' => t('Tests adding various cascading stylesheets to the page.'), - 'group' => t('System') + 'group' => t('System'), ); } function setUp() { - parent::setUp(); + parent::setUp('php'); // Reset drupal_add_css() before each test. drupal_add_css(NULL, 'reset'); } @@ -230,6 +230,48 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { drupal_add_css($css); $this->assertTrue(strpos(drupal_get_css(), $css) > 0, t('Rendered CSS includes the added stylesheet.')); } + + /** + * Tests rendering inline stylesheets with preprocessing on. + */ + function testRenderInlinePreprocess() { + $css = 'body { padding: 0px; }'; + $css_preprocessed = ''; + drupal_add_css($css, 'inline'); + $css = drupal_get_css(); + $this->assertEqual($css, $css_preprocessed, t('Rendering preprocessed inline CSS adds it to the page.')); + } + + /** + * Tests rendering inline stylesheets with preprocessing off. + */ + function testRenderInlineNoPreprocess() { + $css = 'body { padding: 0px; }'; + drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE)); + $this->assertTrue(strpos(drupal_get_css(), $css) > 0, t('Rendering non-preprocessed inline CSS adds it to the page.')); + } + + /** + * Tests rendering inline stylesheets through a full page request. + */ + function testRenderInlineFullPage() { + $css = 'body { padding: 0px; }'; + $compressed_css = ''; + + // Create a node, using the PHP filter that tests drupal_add_css(). + $settings = array( + 'type' => 'page', + 'format' => 3, // PHP filter. + 'body_format' => 3, + 'body' => t('This tests the inline CSS!') . "", + 'promote' => 1, + ); + $node = $this->drupalCreateNode($settings); + + // Fetch the page. + $this->drupalGet('node/' . $node->nid); + $this->assertRaw($compressed_css, t('Inline stylesheets appear in the full page rendering.')); + } } /** -- cgit v1.2.3