| 1 common.test | CommonJavaScriptTestCase::testVersionQueryString() |
Test JavaScript versioning.
File
- core/
modules/ simpletest/ tests/ common.test, line 1549 - Tests for common.inc functionality.
Class
- CommonJavaScriptTestCase
- Tests for the JavaScript system.
Code
function testVersionQueryString() {
$expected = array();
$version = array(
'ajax' => 'bar',
'collapse' => 'foo',
);
// The following code is the same code used by
// backdrop_pre_render_scripts(). If the code in that function is changed,
// the following code needs to be changed too.
$expected['ajax'] = hash('crc32', $version['ajax'] . backdrop_get_hash_salt());
$expected['collapse'] = hash('crc32', $version['collapse'] . backdrop_get_hash_salt());
backdrop_add_js('core/misc/collapse.js', array('version' => $version['collapse']));
backdrop_add_js('core/misc/ajax.js', array('version' => $version['ajax']));
$javascript = backdrop_get_js();
$this->assertTrue(strpos($javascript, "core/misc/collapse.js?{$expected['collapse']}") > 0 && strpos($javascript, "core/misc/ajax.js?{$expected['ajax']}") > 0, t('JavaScript version identifiers correctly appended to URLs'));
}