function JavaScriptTest::testAddInline

Tests adding inline scripts.

File

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

Class

JavaScriptTest
Tests the JavaScript system.

Namespace

Drupal\system\Tests\Common

Code

function testAddInline() {
  drupal_add_library('system', 'drupal');
  $inline = 'jQuery(function () { });';
  $javascript = drupal_add_js($inline, array(
    'type' => 'inline',
    'scope' => 'footer',
  ));
  $this
    ->assertTrue(array_key_exists('core/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.');
}