Make WordPress Core


Ignore:
Timestamp:
10/23/2015 05:53:05 AM (9 years ago)
Author:
dd32
Message:

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

Fixes #34408

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/http/http.php

    r34123 r35369  
    7171     * @dataProvider parse_url_testcases
    7272     */
    73     function test_parse_url( $url, $expected ) {
    74         if ( ! is_callable( array( 'WP_HTTP_Testable', 'parse_url' ) ) ) {
    75             $this->markTestSkipped( "This version of WP_HTTP doesn't support WP_HTTP::parse_url()" );
    76             return;
    77         }
    78         $actual = WP_HTTP_Testable::parse_url( $url );
     73    function test_wp_parse_url( $url, $expected ) {
     74        $actual = wp_parse_url( $url );
    7975        $this->assertEquals( $expected, $actual );
    8076    }
     
    9389            array( 'http://example.com/http://example.net/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/http://example.net/' ) ),
    9490            array( '/path/http://example.net/', array( 'path' => '/path/http://example.net/' ) ),
     91
     92            // < PHP 5.4.7: IPv6 literals in schemeless URLs are handled incorrectly.
     93            array( '//[::FFFF::127.0.0.1]/', array( 'host' => '[::FFFF::127.0.0.1]', 'path' => '/' ) ),
     94
    9595            // PHP's parse_url() calls this an invalid url, we handle it as a path
    9696            array( '/://example.com/', array( 'path' => '/://example.com/' ) ),
     
    104104    }
    105105}
    106 
    107 /**
    108  * A Wrapper of WP_Http to make parse_url() publicaly accessible for testing purposes.
    109  */
    110 class WP_HTTP_Testable extends WP_Http {
    111     public static function parse_url( $url ) {
    112         return parent::parse_url( $url );
    113     }
    114 }
Note: See TracChangeset for help on using the changeset viewer.