Changeset 52187 for trunk/tests/phpunit/tests/functions.php
- Timestamp:
- 11/16/2021 06:48:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions.php
r52010 r52187 664 664 $url = add_query_arg( array( '1' => '2' ), 'foo=bar' ); 665 665 $this->assertSame( 'foo=bar&1=2', $url ); 666 } 667 668 /** 669 * Tests that add_query_arg removes the question mark when 670 * a parameter is set to false. 671 * 672 * @dataProvider data_add_query_arg_removes_question_mark 673 * 674 * @ticket 44499 675 * @group add_query_arg 676 * 677 * @covers ::add_query_arg 678 * 679 * @param string $url Url to test. 680 * @param string $expected Expected URL. 681 */ 682 public function test_add_query_arg_removes_question_mark( $url, $expected, $key = 'param', $value = false ) { 683 $this->assertSame( $expected, add_query_arg( $key, $value, $url ) ); 684 } 685 686 /** 687 * Data provider. 688 * 689 * @return array 690 */ 691 public function data_add_query_arg_removes_question_mark() { 692 return array( 693 'anchor' => array( 694 'url' => 'http://example.org?#anchor', 695 'expected' => 'http://example.org#anchor', 696 ), 697 '/ then anchor' => array( 698 'url' => 'http://example.org/?#anchor', 699 'expected' => 'http://example.org/#anchor', 700 ), 701 'invalid query param and anchor' => array( 702 'url' => 'http://example.org?param=value#anchor', 703 'expected' => 'http://example.org#anchor', 704 ), 705 '/ then invalid query param and anchor' => array( 706 'url' => 'http://example.org/?param=value#anchor', 707 'expected' => 'http://example.org/#anchor', 708 ), 709 '?#anchor when adding valid key/value args' => array( 710 'url' => 'http://example.org?#anchor', 711 'expected' => 'http://example.org?foo=bar#anchor', 712 'key' => 'foo', 713 'value' => 'bar', 714 ), 715 '/?#anchor when adding valid key/value args' => array( 716 'url' => 'http://example.org/?#anchor', 717 'expected' => 'http://example.org/?foo=bar#anchor', 718 'key' => 'foo', 719 'value' => 'bar', 720 ), 721 ); 666 722 } 667 723
Note: See TracChangeset
for help on using the changeset viewer.