From cabab6c1406d325d5d8bc9de3d9bb27324a09ea3 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 21 Jan 2015 18:43:03 +0000 Subject: [PATCH] Use https URLs for wordpress.com assets in `Tests_HTTP_Functions`. The http->https redirects were breaking some of the tests. Fixes #31091. git-svn-id: https://develop.svn.wordpress.org/trunk@31258 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/http/functions.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index 1026e6b1b2..7bb60e863f 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -5,9 +5,17 @@ * @group external-http */ class Tests_HTTP_Functions extends WP_UnitTestCase { + public function setUp() { + if ( ! extension_loaded( 'openssl' ) ) { + $this->markTestSkipped( 'Tests_HTTP_Functions requires openssl.' ); + } + + parent::setUp(); + } + function test_head_request() { // this url give a direct 200 response - $url = 'http://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; $response = wp_remote_head( $url ); $headers = wp_remote_retrieve_headers( $response ); @@ -19,13 +27,13 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { function test_head_redirect() { // this url will 301 redirect - $url = 'http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; $response = wp_remote_head( $url ); $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) ); } function test_head_404() { - $url = 'http://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; + $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; $headers = wp_remote_head( $url ); $this->assertInternalType( 'array', $headers, "Reply wasn't array." ); @@ -33,7 +41,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { } function test_get_request() { - $url = 'http://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; $file = tempnam('/tmp', 'testfile'); $headers = wp_get_http($url, $file); @@ -51,7 +59,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { function test_get_redirect() { // this will redirect to asdftestblog1.files.wordpress.com - $url = 'http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; $file = tempnam('/tmp', 'testfile'); $headers = wp_get_http($url, $file); @@ -69,7 +77,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { function test_get_redirect_limit_exceeded() { // this will redirect to asdftestblog1.files.wordpress.com - $url = 'http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; $file = tempnam('/tmp', 'testfile'); // pretend we've already redirected 5 times $headers = wp_get_http( $url, $file, 6 );