Make WordPress Core


Ignore:
Timestamp:
08/31/2016 12:23:26 AM (8 years ago)
Author:
johnbillion
Message:

HTTP API: Revert changes to wp_parse_url() while PHP 5.2 errors are investigated.

See #36356

File:
1 edited

Legend:

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

    r38453 r38456  
    66 */
    77class Tests_HTTP_HTTP extends WP_UnitTestCase {
    8 
    9     protected static $full_test_url = 'http://username:password@host.name:9090/path?arg1=value1&arg2=value2#anchor';
    108
    119    /**
     
    8179        // 0: The URL, 1: The expected resulting structure
    8280        return array(
    83             array( self::$full_test_url, array(
    84                 'scheme'   => 'http',
    85                 'host'     => 'host.name',
    86                 'port'     => 9090,
    87                 'user'     => 'username',
    88                 'pass'     => 'password',
    89                 'path'     => '/path',
    90                 'query'    => 'arg1=value1&arg2=value2',
    91                 'fragment' => 'anchor',
    92             ) ),
    9381            array( 'http://example.com/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/' ) ),
    9482
     
    9886            array( 'http://example.com//path/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '//path/' ) ),
    9987
    100             // < PHP 5.4.7: Scheme separator in the URL
     88            // < PHP 5.4.7: Scheme seperator in the URL
    10189            array( 'http://example.com/http://example.net/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/http://example.net/' ) ),
    10290            array( '/path/http://example.net/', array( 'path' => '/path/http://example.net/' ) ),
     
    114102          - ://example.com - assumed path in PHP >= 5.4.7, fails in <5.4.7
    115103        */
    116     }
    117 
    118     /**
    119      * @ticket 36356
    120      */
    121     function test_wp_parse_url_with_default_component() {
    122         $actual = wp_parse_url( self::$full_test_url, -1 );
    123         $this->assertEquals( array(
    124             'scheme'   => 'http',
    125             'host'     => 'host.name',
    126             'port'     => 9090,
    127             'user'     => 'username',
    128             'pass'     => 'password',
    129             'path'     => '/path',
    130             'query'    => 'arg1=value1&arg2=value2',
    131             'fragment' => 'anchor',
    132         ), $actual );
    133     }
    134 
    135     /**
    136      * @ticket 36356
    137      *
    138      * @dataProvider parse_url_component_testcases
    139      */
    140     function test_wp_parse_url_with_component( $url, $component, $expected ) {
    141         $actual = wp_parse_url( $url, $component );
    142         $this->assertSame( $expected, $actual );
    143     }
    144 
    145     function parse_url_component_testcases() {
    146         // 0: The URL, 1: The requested component, 2: The expected resulting component.
    147         return array(
    148             array( self::$full_test_url, PHP_URL_SCHEME, 'http' ),
    149             array( self::$full_test_url, PHP_URL_USER, 'username' ),
    150             array( self::$full_test_url, PHP_URL_PASS, 'password' ),
    151             array( self::$full_test_url, PHP_URL_HOST, 'host.name' ),
    152             array( self::$full_test_url, PHP_URL_PORT, 9090 ),
    153             array( self::$full_test_url, PHP_URL_PATH, '/path' ),
    154             array( self::$full_test_url, PHP_URL_QUERY, 'arg1=value1&arg2=value2' ),
    155             array( self::$full_test_url, PHP_URL_FRAGMENT, 'anchor' ),
    156 
    157             // < PHP 5.4.7: Schemeless URL
    158             array( '//example.com/path/', PHP_URL_HOST, 'example.com' ),
    159             array( '//example.com/path/', PHP_URL_PATH, '/path/' ),
    160             array( '//example.com/', PHP_URL_HOST, 'example.com' ),
    161             array( '//example.com/', PHP_URL_PATH, '/' ),
    162             array( 'http://example.com//path/', PHP_URL_HOST, 'example.com' ),
    163             array( 'http://example.com//path/', PHP_URL_PATH, '//path/' ),
    164 
    165             // < PHP 5.4.7: Scheme separator in the URL
    166             array( 'http://example.com/http://example.net/', PHP_URL_HOST, 'example.com' ),
    167             array( 'http://example.com/http://example.net/', PHP_URL_PATH, '/http://example.net/' ),
    168             array( '/path/http://example.net/', PHP_URL_HOST, null ),
    169             array( '/path/http://example.net/', PHP_URL_PATH, '/path/http://example.net/' ),
    170 
    171             // < PHP 5.4.7: IPv6 literals in schemeless URLs are handled incorrectly.
    172             array( '//[::FFFF::127.0.0.1]/', PHP_URL_HOST, '[::FFFF::127.0.0.1]' ),
    173             array( '//[::FFFF::127.0.0.1]/', PHP_URL_PATH, '/' ),
    174 
    175             // PHP's parse_url() calls this an invalid URL, we handle it as a path
    176             array( '/://example.com/', PHP_URL_PATH, '/://example.com/' ),
    177 
    178         );
    179104    }
    180105
Note: See TracChangeset for help on using the changeset viewer.