wiki.techinc.nl/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php
Kunal Mehta 6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00

67 lines
1.6 KiB
PHP

<?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'
]
];
}
}