function JavaScriptTest::testRenderDifferentWeight

Tests rendering the JavaScript with a file's weight above jQuery's.

File

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

Class

JavaScriptTest
Tests the JavaScript system.

Namespace

Drupal\system\Tests\Common

Code

function testRenderDifferentWeight() {

  // JavaScript files are sorted first by group, then by the 'every_page'
  // flag, then by weight (see drupal_sort_css_js()), so to test the effect of
  // weight, we need the other two options to be the same.
  drupal_add_library('system', 'jquery');
  drupal_add_js('core/misc/collapse.js', array(
    'group' => JS_LIBRARY,
    'every_page' => TRUE,
    'weight' => -21,
  ));
  $javascript = drupal_get_js();
  $this
    ->assertTrue(strpos($javascript, 'core/misc/collapse.js') < strpos($javascript, 'core/misc/jquery.js'), 'Rendering a JavaScript file above jQuery.');
}