Changeset 38449 for trunk/tests/phpunit/tests/http/http.php
- Timestamp:
- 08/30/2016 04:35:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/http/http.php
r38430 r38449 7 7 class Tests_HTTP_HTTP extends WP_UnitTestCase { 8 8 9 protected static $full_test_url = 'http://username:password@host.name:9090/path?arg1=value1&arg2=value2#anchor'; 10 9 11 /** 10 12 * @dataProvider make_absolute_url_testcases … … 17 19 18 20 $actual = WP_Http::make_absolute_url( $relative_url, $absolute_url ); 19 $this->assert Equals( $expected, $actual );21 $this->assertSame( $expected, $actual ); 20 22 } 21 23 … … 73 75 function test_wp_parse_url( $url, $expected ) { 74 76 $actual = wp_parse_url( $url ); 75 $this->assert Equals( $expected, $actual );77 $this->assertSame( $expected, $actual ); 76 78 } 77 79 … … 79 81 // 0: The URL, 1: The expected resulting structure 80 82 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 ) ), 81 93 array( 'http://example.com/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/' ) ), 82 94 … … 86 98 array( 'http://example.com//path/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '//path/' ) ), 87 99 88 // < PHP 5.4.7: Scheme sep erator in the URL100 // < PHP 5.4.7: Scheme separator in the URL 89 101 array( 'http://example.com/http://example.net/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/http://example.net/' ) ), 90 102 array( '/path/http://example.net/', array( 'path' => '/path/http://example.net/' ) ), … … 102 114 - ://example.com - assumed path in PHP >= 5.4.7, fails in <5.4.7 103 115 */ 116 } 117 118 /** 119 * @ticket 36356 120 * 121 * @dataProvider parse_url_component_testcases 122 */ 123 function test_wp_parse_url_with_component( $url, $component, $expected ) { 124 $actual = wp_parse_url( $url, $component ); 125 $this->assertSame( $expected, $actual ); 126 } 127 128 function parse_url_component_testcases() { 129 // 0: The URL, 1: The requested component, 2: The expected resulting component. 130 return array( 131 array( self::$full_test_url, -1, array( 132 'scheme' => 'http', 133 'host' => 'host.name', 134 'port' => 9090, 135 'user' => 'username', 136 'pass' => 'password', 137 'path' => '/path', 138 'query' => 'arg1=value1&arg2=value2', 139 'fragment' => 'anchor', 140 ) ), 141 array( self::$full_test_url, PHP_URL_SCHEME, 'http' ), 142 array( self::$full_test_url, PHP_URL_USER, 'username' ), 143 array( self::$full_test_url, PHP_URL_PASS, 'password' ), 144 array( self::$full_test_url, PHP_URL_HOST, 'host.name' ), 145 array( self::$full_test_url, PHP_URL_PORT, 9090 ), 146 array( self::$full_test_url, PHP_URL_PATH, '/path' ), 147 array( self::$full_test_url, PHP_URL_QUERY, 'arg1=value1&arg2=value2' ), 148 array( self::$full_test_url, PHP_URL_FRAGMENT, 'anchor' ), 149 150 // < PHP 5.4.7: Schemeless URL 151 array( '//example.com/path/', PHP_URL_HOST, 'example.com' ), 152 array( '//example.com/path/', PHP_URL_PATH, '/path/' ), 153 array( '//example.com/', PHP_URL_HOST, 'example.com' ), 154 array( '//example.com/', PHP_URL_PATH, '/' ), 155 array( 'http://example.com//path/', PHP_URL_HOST, 'example.com' ), 156 array( 'http://example.com//path/', PHP_URL_PATH, '//path/' ), 157 158 // < PHP 5.4.7: Scheme separator in the URL 159 array( 'http://example.com/http://example.net/', PHP_URL_HOST, 'example.com' ), 160 array( 'http://example.com/http://example.net/', PHP_URL_PATH, '/http://example.net/' ), 161 array( '/path/http://example.net/', PHP_URL_HOST, null ), 162 array( '/path/http://example.net/', PHP_URL_PATH, '/path/http://example.net/' ), 163 164 // < PHP 5.4.7: IPv6 literals in schemeless URLs are handled incorrectly. 165 array( '//[::FFFF::127.0.0.1]/', PHP_URL_HOST, '[::FFFF::127.0.0.1]' ), 166 array( '//[::FFFF::127.0.0.1]/', PHP_URL_PATH, '/' ), 167 168 // PHP's parse_url() calls this an invalid URL, we handle it as a path 169 array( '/://example.com/', PHP_URL_PATH, '/://example.com/' ), 170 171 ); 104 172 } 105 173
Note: See TracChangeset
for help on using the changeset viewer.