Merge branch 'MDL-29161_22' of git://github.com/timhunt/moodle into MOODLE_22_STABLE
This commit is contained in:
@@ -100,6 +100,25 @@ class web_test extends UnitTestCase {
|
||||
$this->assertEqual(wikify_links('this is a <a href="http://someaddress.com/query">link</a>'), 'this is a link [ http://someaddress.com/query ]');
|
||||
}
|
||||
|
||||
function test_moodle_url_round_trip() {
|
||||
$strurl = 'http://moodle.org/course/view.php?id=5';
|
||||
$url = new moodle_url($strurl);
|
||||
$this->assertEqual($strurl, $url->out(false));
|
||||
|
||||
$strurl = 'http://moodle.org/user/index.php?contextid=53&sifirst=M&silast=D';
|
||||
$url = new moodle_url($strurl);
|
||||
$this->assertEqual($strurl, $url->out(false));
|
||||
}
|
||||
|
||||
function test_moodle_url_round_trip_array_params() {
|
||||
$strurl = 'http://example.com/?a%5B1%5D=1&a%5B2%5D=2';
|
||||
$url = new moodle_url($strurl);
|
||||
$this->assertEqual($strurl, $url->out(false));
|
||||
|
||||
$url = new moodle_url('http://example.com/?a[1]=1&a[2]=2');
|
||||
$this->assertEqual($strurl, $url->out(false));
|
||||
}
|
||||
|
||||
function test_compare_url() {
|
||||
$url1 = new moodle_url('index.php', array('var1' => 1, 'var2' => 2));
|
||||
$url2 = new moodle_url('index2.php', array('var1' => 1, 'var2' => 2, 'var3' => 3));
|
||||
|
||||
+7
-1
@@ -474,7 +474,13 @@ class moodle_url {
|
||||
$params = $this->params;
|
||||
}
|
||||
foreach ($params as $key => $val) {
|
||||
$arr[] = rawurlencode($key)."=".rawurlencode($val);
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $index => $value) {
|
||||
$arr[] = rawurlencode($key.'['.$index.']')."=".rawurlencode($value);
|
||||
}
|
||||
} else {
|
||||
$arr[] = rawurlencode($key)."=".rawurlencode($val);
|
||||
}
|
||||
}
|
||||
if ($escaped) {
|
||||
return implode('&', $arr);
|
||||
|
||||
Reference in New Issue
Block a user