Make WordPress Core


Ignore:
Timestamp:
04/15/2024 12:27:18 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.6 branch.

Props peterwilsoncc, jorbin.
See #60865.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

  • branches/5.6/tests/phpunit/tests/http/functions.php

    r49025 r57995  
    1010        function test_head_request() {
    1111                // This URL gives a direct 200 response.
    12                 $url      = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     12                $url      = 'https://s.w.org/screenshots/3.9/dashboard.png';
    1313                $response = wp_remote_head( $url );
    1414
    … …  
    1919                $this->assertInternalType( 'array', $response );
    2020
    21                 $this->assertSame( 'image/jpeg', $headers['content-type'] );
    22                 $this->assertSame( '40148', $headers['content-length'] );
     21                $this->assertSame( 'image/png', $headers['Content-Type'] );
     22                $this->assertSame( '153204', $headers['Content-Length'] );
    2323                $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    2424        }
    … …  
    2626        function test_head_redirect() {
    2727                // This URL will 301 redirect.
    28                 $url      = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     28                $url      = 'https://wp.org/screenshots/3.9/dashboard.png';
    2929                $response = wp_remote_head( $url );
    3030
    … …  
    3333        }
    3434
    35         function test_head_404() {
    36                 $url      = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
     35        /**
     36         * @covers ::wp_remote_head
     37         */
     38        public function test_head_404() {
     39                $url      = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg';
    3740                $response = wp_remote_head( $url );
    3841
    … …  
    4144        }
    4245
    43         function test_get_request() {
    44                 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     46        /**
     47         * @covers ::wp_remote_get
     48         * @covers ::wp_remote_retrieve_headers
     49         * @covers ::wp_remote_retrieve_response_code
     50         */
     51        public function test_get_request() {
     52                $url = 'https://s.w.org/screenshots/3.9/dashboard.png';
    4553
    4654                $response = wp_remote_get( $url );
    … …  
    5361
    5462                // Should return the same headers as a HEAD request.
    55                 $this->assertSame( 'image/jpeg', $headers['content-type'] );
    56                 $this->assertSame( '40148', $headers['content-length'] );
     63                $this->assertSame( 'image/png', $headers['Content-Type'] );
     64                $this->assertSame( '153204', $headers['Content-Length'] );
    5765                $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    5866        }
    5967
    6068        function test_get_redirect() {
    61                 // This will redirect to asdftestblog1.files.wordpress.com.
    62                 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     69                // This will redirect to wordpress.org.
     70                $url = 'https://wp.org/screenshots/3.9/dashboard.png';
    6371
    6472                $response = wp_remote_get( $url );
    … …  
    6977
    7078                // Should return the same headers as a HEAD request.
    71                 $this->assertSame( 'image/jpeg', $headers['content-type'] );
    72                 $this->assertSame( '40148', $headers['content-length'] );
     79                $this->assertSame( 'image/png', $headers['Content-Type'] );
     80                $this->assertSame( '153204', $headers['Content-Length'] );
    7381                $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    7482        }
    7583
    7684        function test_get_redirect_limit_exceeded() {
    77                 // This will redirect to asdftestblog1.files.wordpress.com.
    78                 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     85                // This will redirect to wordpress.org.
     86                $url = 'https://wp.org/screenshots/3.9/dashboard.png';
    7987
    8088                // Pretend we've already redirected 5 times.
Note: See TracChangeset for help on using the changeset viewer.