You are here

function JavaScriptTestCase::testAddInline in Drupal 7

Test adding inline scripts.

File

modules/simpletest/tests/common.test, line 1547
Tests for common.inc functionality.

Class

JavaScriptTestCase
Tests for the JavaScript system.

Code

function testAddInline() {
  $inline = 'jQuery(function () { });';
  $javascript = drupal_add_js($inline, array(
    'type' => 'inline',
    'scope' => 'footer',
  ));
  $this
    ->assertTrue(array_key_exists('misc/jquery.js', $javascript), 'jQuery is added when inline scripts are added.');
  $data = end($javascript);
  $this
    ->assertEqual($inline, $data['data'], 'Inline JavaScript is correctly added to the footer.');
}