1 common.test CommonJavaScriptTestCase::testAlter()

Test altering a JavaScript's weight via hook_js_alter().

See also

simpletest_js_alter()

File

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

Class

CommonJavaScriptTestCase
Tests for the JavaScript system.

Code

function testAlter() {
  // Add both tableselect.js and simpletest.js, with a larger weight on SimpleTest.
  backdrop_add_js('core/misc/tableselect.js');
  backdrop_add_js(backdrop_get_path('module', 'simpletest') . '/js/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 = backdrop_get_js();
  $this->assertTrue(strpos($javascript, 'simpletest.js') < strpos($javascript, 'core/misc/tableselect.js'), 'Altering JavaScript weight through the alter hook.');
}