function CascadingStylesheetsTest::testRenderInlineFullPage

Tests rendering inline stylesheets through a full page request.

File

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

Class

CascadingStylesheetsTest
Tests the Drupal CSS system.

Namespace

Drupal\system\Tests\Common

Code

function testRenderInlineFullPage() {
  module_enable(array(
    'php',
  ));
  $css = 'body { font-size: 254px; }';

  // Inline CSS is minified unless 'preprocess' => FALSE is passed as a
  // drupal_add_css() option.
  $expected = 'body{font-size:254px;}';

  // Create Basic page node type.
  $this
    ->drupalCreateContentType(array(
    'type' => 'page',
    'name' => 'Basic page',
  ));

  // Create a node, using the PHP filter that tests drupal_add_css().
  $php_format_id = 'php_code';
  $settings = array(
    'type' => 'page',
    'body' => array(
      LANGUAGE_NOT_SPECIFIED => array(
        array(
          'value' => t('This tests the inline CSS!') . "<?php drupal_add_css('{$css}', 'inline'); ?>",
          'format' => $php_format_id,
        ),
      ),
    ),
    'promote' => 1,
  );
  $node = $this
    ->drupalCreateNode($settings);

  // Fetch the page.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw($expected, 'Inline stylesheets appear in the full page rendering.');
}