Skip to content

Commit 812ad8d

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 6.4 branch. Props peterwilsoncc, jorbin. See #60865. git-svn-id: https://develop.svn.wordpress.org/branches/6.4@57938 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 17643e8 commit 812ad8d

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
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.wordpress.com/wp-content/uploads/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->assertIsString( $response );
33-
$this->assertSame( 31325, strlen( $response ) );
33+
$this->assertSame( 153204, strlen( $response ) );
3434
}
3535
}

tests/phpunit/tests/http/functions.php

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

1717
$this->skipTestOnTimeout( $response );
@@ -20,8 +20,8 @@ public function test_head_request() {
2020

2121
$this->assertIsArray( $response );
2222

23-
$this->assertSame( 'image/jpeg', $headers['Content-Type'] );
24-
$this->assertSame( '31325', $headers['Content-Length'] );
23+
$this->assertSame( 'image/png', $headers['Content-Type'] );
24+
$this->assertSame( '153204', $headers['Content-Length'] );
2525
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
2626
}
2727

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

3636
$this->skipTestOnTimeout( $response );
@@ -41,7 +41,7 @@ public function test_head_redirect() {
4141
* @covers ::wp_remote_head
4242
*/
4343
public function test_head_404() {
44-
$url = 'https://asdftestblog1.wordpress.com/wp-content/uploads/2007/09/awefasdfawef.jpg';
44+
$url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg';
4545
$response = wp_remote_head( $url );
4646

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

5959
$response = wp_remote_get( $url );
6060

@@ -65,8 +65,8 @@ public function test_get_request() {
6565
$this->assertIsArray( $response );
6666

6767
// Should return the same headers as a HEAD request.
68-
$this->assertSame( 'image/jpeg', $headers['Content-Type'] );
69-
$this->assertSame( '31325', $headers['Content-Length'] );
68+
$this->assertSame( 'image/png', $headers['Content-Type'] );
69+
$this->assertSame( '153204', $headers['Content-Length'] );
7070
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
7171
}
7272

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

8282
$response = wp_remote_get( $url );
8383

@@ -86,17 +86,17 @@ public function test_get_redirect() {
8686
$headers = wp_remote_retrieve_headers( $response );
8787

8888
// Should return the same headers as a HEAD request.
89-
$this->assertSame( 'image/jpeg', $headers['Content-Type'] );
90-
$this->assertSame( '31325', $headers['Content-Length'] );
89+
$this->assertSame( 'image/png', $headers['Content-Type'] );
90+
$this->assertSame( '153204', $headers['Content-Length'] );
9191
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
9292
}
9393

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

101101
// Pretend we've already redirected 5 times.
102102
$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
@@ -623,15 +623,15 @@ public function test_wp_crop_image_with_file() {
623623
*/
624624
public function test_wp_crop_image_with_url() {
625625
$file = wp_crop_image(
626-
'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
626+
'https://s.w.org/screenshots/3.9/dashboard.png',
627627
0,
628628
0,
629629
100,
630630
100,
631631
100,
632632
100,
633633
false,
634-
DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg'
634+
DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png'
635635
);
636636

637637
if ( is_wp_error( $file ) && $file->get_error_code() === 'invalid_image' ) {
@@ -672,7 +672,7 @@ public function test_wp_crop_image_should_fail_with_wp_error_object_if_file_does
672672
*/
673673
public function test_wp_crop_image_should_fail_with_wp_error_object_if_url_does_not_exist() {
674674
$file = wp_crop_image(
675-
'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
675+
'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg',
676676
0,
677677
0,
678678
100,

0 commit comments

Comments
 (0)