HTTP API: Separate the test for wp_parse_url()
with -1
as its component into a separate test, so the remaining tests can use strict type checking. This helps avoid gotches with the potentially empty values (ie. null
) that we're testing for.
See #36356 git-svn-id: https://develop.svn.wordpress.org/trunk@38453 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8a6568945a
commit
7734c6ac24
@ -115,6 +115,23 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 36356
|
||||
*/
|
||||
function test_wp_parse_url_with_default_component() {
|
||||
$actual = wp_parse_url( self::$full_test_url, -1 );
|
||||
$this->assertEquals( array(
|
||||
'scheme' => 'http',
|
||||
'host' => 'host.name',
|
||||
'port' => 9090,
|
||||
'user' => 'username',
|
||||
'pass' => 'password',
|
||||
'path' => '/path',
|
||||
'query' => 'arg1=value1&arg2=value2',
|
||||
'fragment' => 'anchor',
|
||||
), $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 36356
|
||||
*
|
||||
@ -122,22 +139,12 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_wp_parse_url_with_component( $url, $component, $expected ) {
|
||||
$actual = wp_parse_url( $url, $component );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
function parse_url_component_testcases() {
|
||||
// 0: The URL, 1: The requested component, 2: The expected resulting component.
|
||||
return array(
|
||||
array( self::$full_test_url, -1, array(
|
||||
'scheme' => 'http',
|
||||
'host' => 'host.name',
|
||||
'port' => 9090,
|
||||
'user' => 'username',
|
||||
'pass' => 'password',
|
||||
'path' => '/path',
|
||||
'query' => 'arg1=value1&arg2=value2',
|
||||
'fragment' => 'anchor',
|
||||
) ),
|
||||
array( self::$full_test_url, PHP_URL_SCHEME, 'http' ),
|
||||
array( self::$full_test_url, PHP_URL_USER, 'username' ),
|
||||
array( self::$full_test_url, PHP_URL_PASS, 'password' ),
|
||||
|
Loading…
Reference in New Issue
Block a user