Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / GlobalFunctions / wfAppendQueryTest.php
blobbb71610b64e7c9b5c94b6bfda24089c2b4250b0e
1 <?php
3 /**
4 * @group GlobalFunctions
5 * @covers ::wfAppendQuery
6 */
7 class WfAppendQueryTest extends MediaWikiTestCase {
8 /**
9 * @dataProvider provideAppendQuery
11 public function testAppendQuery( $url, $query, $expected, $message = null ) {
12 $this->assertEquals( $expected, wfAppendQuery( $url, $query ), $message );
15 public static function provideAppendQuery() {
16 return [
18 'http://www.example.org/index.php',
19 '',
20 'http://www.example.org/index.php',
21 'No query'
24 'http://www.example.org/index.php',
25 [ 'foo' => 'bar' ],
26 'http://www.example.org/index.php?foo=bar',
27 'Set query array'
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'
36 'http://www.example.org/index.php?foo=bar',
37 '',
38 'http://www.example.org/index.php?foo=bar',
39 'Empty string with query'
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'
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'
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'
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'
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'
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'