WP_HTTP: Promote the WP_HTTP::parse_url() method to a more generic wp_parse_url() function.

Fixes #34408


git-svn-id: https://develop.svn.wordpress.org/trunk@35369 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse
2015-10-23 05:53:05 +00:00
parent 743fe671f1
commit cacd015856
3 changed files with 57 additions and 49 deletions

View File

@@ -70,12 +70,8 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
/**
* @dataProvider parse_url_testcases
*/
function test_parse_url( $url, $expected ) {
if ( ! is_callable( array( 'WP_HTTP_Testable', 'parse_url' ) ) ) {
$this->markTestSkipped( "This version of WP_HTTP doesn't support WP_HTTP::parse_url()" );
return;
}
$actual = WP_HTTP_Testable::parse_url( $url );
function test_wp_parse_url( $url, $expected ) {
$actual = wp_parse_url( $url );
$this->assertEquals( $expected, $actual );
}
@@ -92,6 +88,10 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
// < PHP 5.4.7: Scheme seperator in the URL
array( 'http://example.com/http://example.net/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/http://example.net/' ) ),
array( '/path/http://example.net/', array( 'path' => '/path/http://example.net/' ) ),
// < PHP 5.4.7: IPv6 literals in schemeless URLs are handled incorrectly.
array( '//[::FFFF::127.0.0.1]/', array( 'host' => '[::FFFF::127.0.0.1]', 'path' => '/' ) ),
// PHP's parse_url() calls this an invalid url, we handle it as a path
array( '/://example.com/', array( 'path' => '/://example.com/' ) ),
@@ -103,12 +103,3 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
*/
}
}
/**
* A Wrapper of WP_Http to make parse_url() publicaly accessible for testing purposes.
*/
class WP_HTTP_Testable extends WP_Http {
public static function parse_url( $url ) {
return parent::parse_url( $url );
}
}