1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
/**
* @group GlobalFunctions
* @covers ::wfAppendQuery
*/
class WfAppendQueryTest extends MediaWikiTestCase {
/**
* @dataProvider provideAppendQuery
*/
public function testAppendQuery( $url, $query, $expected, $message = null ) {
$this->assertEquals( $expected, wfAppendQuery( $url, $query ), $message );
}
public static function provideAppendQuery() {
return [
[
'http://www.example.org/index.php',
'',
'http://www.example.org/index.php',
'No query'
],
[
'http://www.example.org/index.php',
[ 'foo' => 'bar' ],
'http://www.example.org/index.php?foo=bar',
'Set query array'
],
[
'http://www.example.org/index.php?foz=baz',
'foo=bar',
'http://www.example.org/index.php?foz=baz&foo=bar',
'Set query string'
],
[
'http://www.example.org/index.php?foo=bar',
'',
'http://www.example.org/index.php?foo=bar',
'Empty string with query'
],
[
'http://www.example.org/index.php?foo=bar',
[ 'baz' => 'quux' ],
'http://www.example.org/index.php?foo=bar&baz=quux',
'Add query array'
],
[
'http://www.example.org/index.php?foo=bar',
'baz=quux',
'http://www.example.org/index.php?foo=bar&baz=quux',
'Add query string'
],
[
'http://www.example.org/index.php?foo=bar',
[ 'baz' => 'quux', 'foo' => 'baz' ],
'http://www.example.org/index.php?foo=bar&baz=quux&foo=baz',
'Modify query array'
],
[
'http://www.example.org/index.php?foo=bar',
'baz=quux&foo=baz',
'http://www.example.org/index.php?foo=bar&baz=quux&foo=baz',
'Modify query string'
],
[
'http://www.example.org/index.php#baz',
'foo=bar',
'http://www.example.org/index.php?foo=bar#baz',
'URL with fragment'
],
[
'http://www.example.org/index.php?foo=bar#baz',
'quux=blah',
'http://www.example.org/index.php?foo=bar&quux=blah#baz',
'URL with query string and fragment'
]
];
}
}
|