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