Skip to content

Commit

Permalink
Tests: Update expectations in wp_remote_head() and `wp_remote_get()…
Browse files Browse the repository at this point in the history
…` tests.

It appears that something has changed on the WP.com side to compress the requested images on the fly, which interfered with the previous expectations in these tests.

This commit uses a direct file URL and updates the expected image size to match the currently returned response.

Follow-up to [139/tests], [31258], [47142].

Props dextorlobo, swissspidy, davidbaumwald, SergeyBiryukov.
See #60865.

git-svn-id: https://develop.svn.wordpress.org/trunk@57903 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Apr 1, 2024
1 parent b094b53 commit 7d7b92a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/phpunit/tests/functions/wpRemoteFopen.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,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://asdftestblog1.wordpress.com/wp-content/uploads/2007/09/2007-06-30-dsc_4700-1.jpg';
$response = wp_remote_fopen( $url );

$this->assertIsString( $response );
$this->assertSame( 40148, strlen( $response ) );
$this->assertSame( 31325, strlen( $response ) );
}
}
10 changes: 5 additions & 5 deletions tests/phpunit/tests/http/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
*/
public 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://asdftestblog1.wordpress.com/wp-content/uploads/2007/09/2007-06-30-dsc_4700-1.jpg';
$response = wp_remote_head( $url );

$this->skipTestOnTimeout( $response );
Expand All @@ -21,7 +21,7 @@ public function test_head_request() {
$this->assertIsArray( $response );

$this->assertSame( 'image/jpeg', $headers['Content-Type'] );
$this->assertSame( '40148', $headers['Content-Length'] );
$this->assertSame( '31325', $headers['Content-Length'] );
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
}

Expand All @@ -41,7 +41,7 @@ public function test_head_redirect() {
* @covers ::wp_remote_head
*/
public function test_head_404() {
$url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
$url = 'https://asdftestblog1.wordpress.com/wp-content/uploads/2007/09/awefasdfawef.jpg';
$response = wp_remote_head( $url );

$this->skipTestOnTimeout( $response );
Expand All @@ -66,7 +66,7 @@ public function test_get_request() {

// Should return the same headers as a HEAD request.
$this->assertSame( 'image/jpeg', $headers['Content-Type'] );
$this->assertSame( '40148', $headers['Content-Length'] );
$this->assertSame( '31325', $headers['Content-Length'] );
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
}

Expand All @@ -87,7 +87,7 @@ public function test_get_redirect() {

// Should return the same headers as a HEAD request.
$this->assertSame( 'image/jpeg', $headers['Content-Type'] );
$this->assertSame( '40148', $headers['Content-Length'] );
$this->assertSame( '31325', $headers['Content-Length'] );
$this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
}

Expand Down

0 comments on commit 7d7b92a

Please sign in to comment.