function JavaScriptTestCase::testRenderDifferentWeight in Drupal 7
Test rendering the JavaScript with a file's weight above jQuery's.
File
- modules/
simpletest/ tests/ common.test, line 1808 - Tests for common.inc functionality.
Class
- JavaScriptTestCase
- Tests for the JavaScript system.
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_js('misc/collapse.js', array(
'group' => JS_LIBRARY,
'every_page' => TRUE,
'weight' => -21,
));
$javascript = drupal_get_js();
$this
->assertTrue(strpos($javascript, 'misc/collapse.js') < strpos($javascript, 'misc/jquery.js'), 'Rendering a JavaScript file above jQuery.');
}