function JavaScriptTestCase::testAlter in Drupal 7
Test altering a JavaScript's weight via hook_js_alter().
See also
File
- modules/
simpletest/ tests/ common.test, line 1822 - Tests for common.inc functionality.
Class
- JavaScriptTestCase
- Tests for the JavaScript system.
Code
function testAlter() {
// Add both tableselect.js and simpletest.js, with a larger weight on SimpleTest.
drupal_add_js('misc/tableselect.js');
drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', array(
'weight' => 9999,
));
// Render the JavaScript, testing if simpletest.js was altered to be before
// tableselect.js. See simpletest_js_alter() to see where this alteration
// takes place.
$javascript = drupal_get_js();
$this
->assertTrue(strpos($javascript, 'simpletest.js') < strpos($javascript, 'misc/tableselect.js'), 'Altering JavaScript weight through the alter hook.');
}