From 7734c6ac24c07cb2bfa64559cc1a12a38afe749e Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 30 Aug 2016 18:30:51 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/http/http.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/http/http.php b/tests/phpunit/tests/http/http.php index e3694a9bae..871c5d231c 100644 --- a/tests/phpunit/tests/http/http.php +++ b/tests/phpunit/tests/http/http.php @@ -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' ),