Skip to content

Commit 5bdbd99

Browse files
Tests: Use an image on WordPress.org CDN in external HTTP tests.
Due to some changes on the WP.com side to compress the requested images on the fly, the exact image size in the response could be different between platforms. This commit aims to make the affected tests more reliable. Follow-up to [139/tests], [31258], [34568], [47142], [57903], [57904], [57924]. Merges [57931] to the 5.7 branch. Props peterwilsoncc, jorbin. See #60865. git-svn-id: https://develop.svn.wordpress.org/branches/5.7@57994 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 01cb4ed commit 5bdbd99

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

tests/phpunit/tests/functions/wpRemoteFopen.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public function test_wp_remote_fopen_bad_url() {
2626
*/
2727
public function test_wp_remote_fopen() {
2828
// This URL gives a direct 200 response.
29-
$url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
29+
$url = 'https://s.w.org/screenshots/3.9/dashboard.png';
3030
$response = wp_remote_fopen( $url );
3131

3232
$this->assertInternalType( 'string', $response );
33-
$this->assertSame( 40148, strlen( $response ) );
33+
$this->assertSame( 153204, strlen( $response ) );
3434
}
3535
}

tests/phpunit/tests/http/functions.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
1212
*/
1313
function test_head_request() {
1414
// This URL gives a direct 200 response.
15-
$url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
15+
$url = 'https://s.w.org/screenshots/3.9/dashboard.png';
1616
$response = wp_remote_head( $url );
1717

1818
$this->skipTestOnTimeout( $response );
@@ -21,8 +21,8 @@ function test_head_request() {
2121

2222
$this->assertInternalType( 'array', $response );
2323

24-
$this->assertSame( 'image/jpeg', $headers['content-type'] );
25-
$this->assertSame( '40148', $headers['content-length'] );
24+
$this->assertSame( 'image/png', $headers['Content-Type'] );
25+
$this->assertSame( '153204', $headers['Content-Length'] );
2626
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
2727
}
2828

@@ -31,7 +31,7 @@ function test_head_request() {
3131
*/
3232
function test_head_redirect() {
3333
// This URL will 301 redirect.
34-
$url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
34+
$url = 'https://wp.org/screenshots/3.9/dashboard.png';
3535
$response = wp_remote_head( $url );
3636

3737
$this->skipTestOnTimeout( $response );
@@ -41,8 +41,8 @@ function test_head_redirect() {
4141
/**
4242
* @covers ::wp_remote_head
4343
*/
44-
function test_head_404() {
45-
$url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
44+
public function test_head_404() {
45+
$url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg';
4646
$response = wp_remote_head( $url );
4747

4848
$this->skipTestOnTimeout( $response );
@@ -54,8 +54,8 @@ function test_head_404() {
5454
* @covers ::wp_remote_retrieve_headers
5555
* @covers ::wp_remote_retrieve_response_code
5656
*/
57-
function test_get_request() {
58-
$url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
57+
public function test_get_request() {
58+
$url = 'https://s.w.org/screenshots/3.9/dashboard.png';
5959

6060
$response = wp_remote_get( $url );
6161

@@ -66,8 +66,8 @@ function test_get_request() {
6666
$this->assertInternalType( 'array', $response );
6767

6868
// Should return the same headers as a HEAD request.
69-
$this->assertSame( 'image/jpeg', $headers['content-type'] );
70-
$this->assertSame( '40148', $headers['content-length'] );
69+
$this->assertSame( 'image/png', $headers['Content-Type'] );
70+
$this->assertSame( '153204', $headers['Content-Length'] );
7171
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
7272
}
7373

@@ -77,8 +77,8 @@ function test_get_request() {
7777
* @covers ::wp_remote_retrieve_response_code
7878
*/
7979
function test_get_redirect() {
80-
// This will redirect to asdftestblog1.files.wordpress.com.
81-
$url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
80+
// This will redirect to wordpress.org.
81+
$url = 'https://wp.org/screenshots/3.9/dashboard.png';
8282

8383
$response = wp_remote_get( $url );
8484

@@ -87,17 +87,17 @@ function test_get_redirect() {
8787
$headers = wp_remote_retrieve_headers( $response );
8888

8989
// Should return the same headers as a HEAD request.
90-
$this->assertSame( 'image/jpeg', $headers['content-type'] );
91-
$this->assertSame( '40148', $headers['content-length'] );
90+
$this->assertSame( 'image/png', $headers['Content-Type'] );
91+
$this->assertSame( '153204', $headers['Content-Length'] );
9292
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
9393
}
9494

9595
/**
9696
* @covers ::wp_remote_get
9797
*/
9898
function test_get_redirect_limit_exceeded() {
99-
// This will redirect to asdftestblog1.files.wordpress.com.
100-
$url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
99+
// This will redirect to wordpress.org.
100+
$url = 'https://wp.org/screenshots/3.9/dashboard.png';
101101

102102
// Pretend we've already redirected 5 times.
103103
$response = wp_remote_get( $url, array( 'redirection' => -1 ) );

tests/phpunit/tests/image/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,15 @@ public function test_wp_crop_image_file() {
368368
*/
369369
public function test_wp_crop_image_url() {
370370
$file = wp_crop_image(
371-
'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
371+
'https://s.w.org/screenshots/3.9/dashboard.png',
372372
0,
373373
0,
374374
100,
375375
100,
376376
100,
377377
100,
378378
false,
379-
DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg'
379+
DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png'
380380
);
381381

382382
if ( is_wp_error( $file ) && $file->get_error_code() === 'invalid_image' ) {
@@ -411,7 +411,7 @@ public function test_wp_crop_image_file_not_exist() {
411411
*/
412412
public function test_wp_crop_image_url_not_exist() {
413413
$file = wp_crop_image(
414-
'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
414+
'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg',
415415
0,
416416
0,
417417
100,

0 commit comments

Comments
 (0)