Make WordPress Core


Ignore:
Timestamp:
04/15/2024 12:22:26 PM (10 months 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.8 branch.

Props peterwilsoncc, jorbin.
See #60865.

Location:
branches/5.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

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

    r50344 r57993  
    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
     
    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    }
     
    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
     
    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
     
    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 );
     
    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    }
     
    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 );
     
    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    }
     
    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.
Note: See TracChangeset for help on using the changeset viewer.