| 1 | <?php |
| 2 | /** |
| 3 | * @group functions.php |
| 4 | */ |
| 5 | class Tests_Functions_GetQueryArg extends WP_UnitTestCase { |
| 6 | |
| 7 | /** |
| 8 | * @ticket 34699 |
| 9 | */ |
| 10 | public function test_get_query_arg() { |
| 11 | $this->assertSame( 'value2', get_query_arg( 'param2', '?param=test¶m2=value2' ) ); |
| 12 | $this->assertNotSame( 'value2', get_query_arg( 'param3', '?param=test¶m2=value2¶m3=value3' ) ); |
| 13 | |
| 14 | // When the key is an array |
| 15 | $this->assertEquals( |
| 16 | array( 'param2' => 'value2', 'param3' => 'value3', 'param4' => null ), |
| 17 | get_query_arg( array( 'param2', 'param3', 'param4' ), '?param=test¶m2=value2¶m3=value3' ) |
| 18 | ); |
| 19 | |
| 20 | // When arg doesn't exists. |
| 21 | $this->assertNull( get_query_arg( 'param2', '?param=test' ) ); |
| 22 | |
| 23 | // When no query is present. |
| 24 | $this->assertSame( array( 'param' => null ), get_query_arg( array( 'param' ), '' ) ); |
| 25 | $this->assertNull( get_query_arg( 'value', '' ) ); |
| 26 | |
| 27 | // Fallback on REQUEST_URI. |
| 28 | $this->assertNull( get_query_arg( 'param' ) ); |
| 29 | } |
| 30 | |
| 31 | } |
| 32 | No newline at end of file |