From 9f21bd49bc79f6ee97b7954ae99e309a4f65744b Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 3 Jun 2016 04:30:23 +0000 Subject: [PATCH] Add tests for `remove_query_arg()`. Props borgesbruno. Fixes #37008. git-svn-id: https://develop.svn.wordpress.org/trunk@37631 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/functions/removeQueryArg.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/phpunit/tests/functions/removeQueryArg.php diff --git a/tests/phpunit/tests/functions/removeQueryArg.php b/tests/phpunit/tests/functions/removeQueryArg.php new file mode 100644 index 0000000000..d848a36082 --- /dev/null +++ b/tests/phpunit/tests/functions/removeQueryArg.php @@ -0,0 +1,37 @@ +assertNotEmpty( $actual ); + $this->assertEquals( $expected, $actual ); + } + + public function remove_query_arg_provider() { + return array( + array( 'foo', 'edit.php?foo=test1&baz=test1', 'edit.php?baz=test1' ), + array( array( 'foo' ), 'edit.php?foo=test2&baz=test2', 'edit.php?baz=test2' ), + array( array( 'foo', 'baz' ), 'edit.php?foo=test3&baz=test3', 'edit.php' ), + array( array( 'fakefoo', 'fakebaz' ), 'edit.php?foo=test4&baz=test4', 'edit.php?foo=test4&baz=test4' ), + array( array( 'fakefoo', 'baz' ), 'edit.php?foo=test4&baz=test4', 'edit.php?foo=test4' ), + ); + } + + public function test_should_fall_back_on_current_url() { + $old_request_uri = $_SERVER['REQUEST_URI']; + $_SERVER['REQUEST_URI'] = 'edit.php?foo=bar&baz=quz'; + + $actual = remove_query_arg( 'foo' ); + + $_SERVER['REQUEST_URI'] = $old_request_uri; + + $this->assertSame( 'edit.php?baz=quz', $actual ); + } +}