Add some unit tests for WP_HTTP::parse_url() to cover the <PHP 5.4.7 compatibility alterations.

These unit tests cover the expected vehaviour of certain combinations of URL's, but makes no attempt to test invalid URL structures, as PHP's behavious for invalid URL's is undefined (Some will be treated as paths, others fail, and it varies between PHP 5.4.7+ and <5.4.7).
This change also makes WP_HTTP::parse_url() protected in order to allow unit testing.
See #28001, #29886

Built from https://develop.svn.wordpress.org/trunk@29864


git-svn-id: http://core.svn.wordpress.org/trunk@29624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2014-10-09 03:01:18 +00:00
parent 61317341eb
commit 659a6b3838

View File

@ -682,11 +682,11 @@ class WP_Http {
*
* @since 4.1.0
*
* @access private
* @access protected
* @param string $url The URL to parse
* @return bool|array False on failure; Array of URL components on success; See parse_url()'s return values.
*/
private static function parse_url( $url ) {
protected static function parse_url( $url ) {
$parts = @parse_url( $url );
if ( ! $parts ) {
// < PHP 5.4.7 compat, trouble with relative paths including a scheme break in the path