mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-02 01:20:03 +00:00
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:
@@ -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 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user