X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php diff --git a/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php b/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php new file mode 100644 index 00000000..bb71610b --- /dev/null +++ b/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php @@ -0,0 +1,79 @@ +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' + ] + ]; + } +}