Merge "Import: Fix error reporting"
[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 array(
17 array(
18 'http://www.example.org/index.php',
19 '',
20 'http://www.example.org/index.php',
21 'No query'
22 ),
23 array(
24 'http://www.example.org/index.php',
25 array( 'foo' => 'bar' ),
26 'http://www.example.org/index.php?foo=bar',
27 'Set query array'
28 ),
29 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'
34 ),
35 array(
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 array(
42 'http://www.example.org/index.php?foo=bar',
43 array( 'baz' => 'quux' ),
44 'http://www.example.org/index.php?foo=bar&baz=quux',
45 'Add query array'
46 ),
47 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'
52 ),
53 array(
54 'http://www.example.org/index.php?foo=bar',
55 array( 'baz' => 'quux', 'foo' => 'baz' ),
56 'http://www.example.org/index.php?foo=bar&baz=quux&foo=baz',
57 'Modify query array'
58 ),
59 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'
64 )
65 );
66 }
67 }