mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-47073-master' of git://github.com/junpataleta/moodle
This commit is contained in:
commit
df8095156e
2 changed files with 40 additions and 0 deletions
|
@ -556,6 +556,8 @@ class page_requirements_manager {
|
|||
$path = realpath("$componentdir/jquery/$file");
|
||||
if (strpos($path, $CFG->dirroot) === 0) {
|
||||
$url = $CFG->httpswwwroot.preg_replace('/^'.preg_quote($CFG->dirroot, '/').'/', '', $path);
|
||||
// Replace all occurences of backslashes characters in url to forward slashes.
|
||||
$url = str_replace('\\', '/', $url);
|
||||
$url = new moodle_url($url);
|
||||
} else {
|
||||
// Bad luck, fix your server!
|
||||
|
|
|
@ -63,4 +63,42 @@ class core_outputrequirementslib_testcase extends advanced_testcase {
|
|||
$this->assertTrue($secondpage->requires->should_create_one_time_item_now('test_item'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for the jquery_plugin method.
|
||||
*
|
||||
* Test to make sure that backslashes are not generated with either slasharguments set to on or off.
|
||||
*/
|
||||
public function test_jquery_plugin() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
// With slasharguments on.
|
||||
$CFG->slasharguments = 1;
|
||||
|
||||
$page = new moodle_page();
|
||||
$requirements = $page->requires;
|
||||
// Assert successful method call.
|
||||
$this->assertTrue($requirements->jquery_plugin('jquery'));
|
||||
$this->assertTrue($requirements->jquery_plugin('ui'));
|
||||
|
||||
// Get the code containing the required jquery plugins.
|
||||
$requirecode = $requirements->get_top_of_body_code();
|
||||
// Make sure that the generated code does not contain backslashes.
|
||||
$this->assertFalse(strpos($requirecode, '\\'), "Output contains backslashes: " . $requirecode);
|
||||
|
||||
// With slasharguments off.
|
||||
$CFG->slasharguments = 0;
|
||||
|
||||
$page = new moodle_page();
|
||||
$requirements = $page->requires;
|
||||
// Assert successful method call.
|
||||
$this->assertTrue($requirements->jquery_plugin('jquery'));
|
||||
$this->assertTrue($requirements->jquery_plugin('ui'));
|
||||
|
||||
// Get the code containing the required jquery plugins.
|
||||
$requirecode = $requirements->get_top_of_body_code();
|
||||
// Make sure that the generated code does not contain backslashes.
|
||||
$this->assertFalse(strpos($requirecode, '\\'), "Output contains backslashes: " . $requirecode);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue