Make WordPress Core

Ticket #37008: 37008.diff

File 37008.diff, 1.3 KB (added by borgesbruno, 9 years ago)
  • tests/phpunit/tests/functions.php

     
    887887
    888888                $this->assertNull( wp_ext2type( 'unknown_format' ) );
    889889        }
     890
     891        /**
     892         * @ticket 37008
     893         * @dataProvider uri_list_provider
     894         */
     895        public function test_remove_query_arg( $actual, $expected, $keys_to_remove ) {
     896                $old_request_uri = $_SERVER['REQUEST_URI'];
     897                $_SERVER['REQUEST_URI'] = $actual;
     898
     899                $uri_result = remove_query_arg( $keys_to_remove );
     900
     901                $this->assertNotEmpty( $uri_result, 'The URI cannot to be empty' );
     902                $this->assertEquals(
     903                        $expected,
     904                        $uri_result,
     905                        "The final URI after removing the keys isn't the expected one"
     906                );
     907
     908                $_SERVER['REQUEST_URI'] = $old_request_uri;
     909        }
     910
     911        function uri_list_provider() {
     912                return array(
     913                        array( 'edit.php?foo=test1&baz=test1', 'edit.php?baz=test1' , 'foo' ),
     914                        array( 'edit.php?foo=test2&baz=test2', 'edit.php?baz=test2' , array( 'foo' ) ),
     915                        array( 'edit.php?foo=test3&baz=test3', 'edit.php' , array( 'foo', 'baz' ) ),
     916                        array( 'edit.php?foo=test4&baz=test4', 'edit.php?foo=test4&baz=test4' , array( 'fakefoo', 'fakebaz' ) ),
     917                        array( 'edit.php?foo=test4&baz=test4', 'edit.php?foo=test4' , array( 'fakefoo', 'baz' ) ),
     918                );
     919        }
    890920}