You are here

function JavaScriptTestCase::testAlter in SimpleTest 7

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

See also

simpletest_js_alter()

File

tests/common.test, line 1133
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' => JS_THEME,
  ));

  // 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'), t('Altering JavaScript weight through the alter hook.'));
}