diff --git a/tests/phpunit/tests/functions/wpRemoteFopen.php b/tests/phpunit/tests/functions/wpRemoteFopen.php index b5627da800ee8..38d9dce006adc 100644 --- a/tests/phpunit/tests/functions/wpRemoteFopen.php +++ b/tests/phpunit/tests/functions/wpRemoteFopen.php @@ -25,10 +25,10 @@ public function test_wp_remote_fopen_bad_url() { */ public function test_wp_remote_fopen() { // This URL gives a direct 200 response. - $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; $response = wp_remote_fopen( $url ); - $this->assertInternalType( 'string', $response ); - $this->assertEquals( 40148, strlen( $response ) ); + $this->assertIsString( $response ); + $this->assertSame( 153204, strlen( $response ) ); } } diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index de272d9a0e0c5..9cf58b5656bc8 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -16,7 +16,7 @@ public function setUp() { function test_head_request() { // This URL gives a direct 200 response. - $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); @@ -25,30 +25,38 @@ function test_head_request() { $this->assertInternalType( 'array', $response ); - $this->assertEquals( 'image/jpeg', $headers['content-type'] ); - $this->assertEquals( '40148', $headers['content-length'] ); - $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 'image/png', $headers['Content-Type'] ); + $this->assertSame( '153204', $headers['Content-Length'] ); + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } function test_head_redirect() { // This URL will 301 redirect. - $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; + $url = 'https://wp.org/screenshots/3.9/dashboard.png'; $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) ); } - function test_head_404() { - $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; + /** + * @covers ::wp_remote_head + */ + public function test_head_404() { + $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg'; $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); $this->assertEquals( '404', wp_remote_retrieve_response_code( $response ) ); } - function test_get_request() { - $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; + /** + * @covers ::wp_remote_get + * @covers ::wp_remote_retrieve_headers + * @covers ::wp_remote_retrieve_response_code + */ + public function test_get_request() { + $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; $response = wp_remote_get( $url ); @@ -59,14 +67,14 @@ function test_get_request() { $this->assertInternalType( 'array', $response ); // Should return the same headers as a HEAD request. - $this->assertEquals( 'image/jpeg', $headers['content-type'] ); - $this->assertEquals( '40148', $headers['content-length'] ); - $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 'image/png', $headers['Content-Type'] ); + $this->assertSame( '153204', $headers['Content-Length'] ); + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } function test_get_redirect() { - // This will redirect to asdftestblog1.files.wordpress.com. - $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; + // This will redirect to wordpress.org. + $url = 'https://wp.org/screenshots/3.9/dashboard.png'; $response = wp_remote_get( $url ); @@ -75,14 +83,14 @@ function test_get_redirect() { $headers = wp_remote_retrieve_headers( $response ); // Should return the same headers as a HEAD request. - $this->assertEquals( 'image/jpeg', $headers['content-type'] ); - $this->assertEquals( '40148', $headers['content-length'] ); - $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 'image/png', $headers['Content-Type'] ); + $this->assertSame( '153204', $headers['Content-Length'] ); + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } function test_get_redirect_limit_exceeded() { - // This will redirect to asdftestblog1.files.wordpress.com. - $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; + // This will redirect to wordpress.org. + $url = 'https://wp.org/screenshots/3.9/dashboard.png'; // Pretend we've already redirected 5 times. $response = wp_remote_get( $url, array( 'redirection' => -1 ) ); diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 4a7713d52b670..1e80d12e7950c 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -335,7 +335,7 @@ public function test_wp_crop_image_url() { } $file = wp_crop_image( - 'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg', + 'https://s.w.org/screenshots/3.9/dashboard.png', 0, 0, 100, @@ -343,7 +343,7 @@ public function test_wp_crop_image_url() { 100, 100, false, - DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg' + DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png' ); $this->assertNotWPError( $file ); $this->assertFileExists( $file ); @@ -374,7 +374,7 @@ public function test_wp_crop_image_url_not_exist() { } $file = wp_crop_image( - 'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg', + 'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg', 0, 0, 100,