function JavaScriptTestCase::testAddFile in Drupal 7
Test adding a JavaScript file.
File
- modules/
simpletest/ tests/ common.test, line 1472 - Tests for common.inc functionality.
Class
- JavaScriptTestCase
- Tests for the JavaScript system.
Code
function testAddFile() {
$javascript = drupal_add_js('misc/collapse.js');
$this
->assertTrue(array_key_exists('misc/jquery.js', $javascript), 'jQuery is added when a file is added.');
$this
->assertTrue(array_key_exists('misc/drupal.js', $javascript), 'Drupal.js is added when file is added.');
$this
->assertTrue(array_key_exists('misc/collapse.js', $javascript), 'JavaScript files are correctly added.');
$this
->assertEqual(base_path(), $javascript['settings']['data'][0]['basePath'], 'Base path JavaScript setting is correctly set.');
url('', array(
'prefix' => &$prefix,
));
$this
->assertEqual(empty($prefix) ? '' : $prefix, $javascript['settings']['data'][1]['pathPrefix'], 'Path prefix JavaScript setting is correctly set.');
}