Changeset 29864 for trunk/tests/phpunit/tests/http/http.php
- Timestamp:
- 10/09/2014 03:00:16 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/http/http.php
r29851 r29864 67 67 ); 68 68 } 69 70 /** 71 * @dataProvider parse_url_testcases 72 */ 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 ); 79 $this->assertEquals( $expected, $actual ); 80 } 81 82 function parse_url_testcases() { 83 // 0: The URL, 1: The expected resulting structure 84 return array( 85 array( 'http://example.com/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/' ) ), 86 87 // < PHP 5.4.7: Schemeless URL 88 array( '//example.com/path/', array( 'host' => 'example.com', 'path' => '/path/' ) ), 89 array( '//example.com/', array( 'host' => 'example.com', 'path' => '/' ) ), 90 array( 'http://example.com//path/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '//path/' ) ), 91 92 // < PHP 5.4.7: Scheme seperator in the URL 93 array( 'http://example.com/http://example.net/', array( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/http://example.net/' ) ), 94 array( '/path/http://example.net/', array( 'path' => '/path/http://example.net/' ) ), 95 // PHP's parse_url() calls this an invalid url, we handle it as a path 96 array( '/://example.com/', array( 'path' => '/://example.com/' ) ), 97 98 ); 99 /* 100 Untestable edge cases in various PHP: 101 - ///example.com - Fails in PHP >= 5.4.7, assumed path in <5.4.7 102 - ://example.com - assumed path in PHP >= 5.4.7, fails in <5.4.7 103 */ 104 } 69 105 } 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.