public function js($jsfile, $fullurl = false) {
global $CFG;
if (!$fullurl) {
- if (!file_exists($CFG->dirroot . '/' . $jsfile)) {
+ // strtok is used to trim off any GET string arguments before looking for the file
+ if (!file_exists($CFG->dirroot . '/' . strtok($jsfile, '?'))) {
throw new coding_exception('Attept to require a JavaScript file that does not exist.', $jsfile);
}
$url = $CFG->httpswwwroot . '/' . $jsfile;
$this->assertContains($html, $CFG->httpswwwroot . '/' . $jsfile);
}
+ public function test_requiring_js_with_argument() {
+ global $CFG;
+ $jsfile = 'lib/javascript-static.js?d=434'; // Just needs to be a JS file that exists.
+ $this->requires->js($jsfile);
+
+ $html = $this->requires->get_end_code();
+ $this->assertContains($html, $CFG->httpswwwroot . '/' . $jsfile);
+ }
+
public function test_nonexistant_js_throws_exception() {
$cssfile = 'js/file/that/does/not/exist.js';