Make WordPress Core

Changeset 57996


Ignore:
Timestamp:
04/15/2024 12:28:32 PM (2 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.5 branch.

Props peterwilsoncc, jorbin.
See #60865.

Location:
branches/5.5
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/tests/phpunit/tests/functions/wpRemoteFopen.php

    r47780 r57996  
    2626    public function test_wp_remote_fopen() {
    2727        // This URL gives a direct 200 response.
    28         $url      = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     28        $url      = 'https://s.w.org/screenshots/3.9/dashboard.png';
    2929        $response = wp_remote_fopen( $url );
    3030
    31         $this->assertInternalType( 'string', $response );
    32         $this->assertEquals( 40148, strlen( $response ) );
     31        $this->assertIsString( $response );
     32        $this->assertSame( 153204, strlen( $response ) );
    3333    }
    3434}
  • branches/5.5/tests/phpunit/tests/http/functions.php

    r47122 r57996  
    1717    function test_head_request() {
    1818        // This URL gives a direct 200 response.
    19         $url      = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     19        $url      = 'https://s.w.org/screenshots/3.9/dashboard.png';
    2020        $response = wp_remote_head( $url );
    2121
     
    2626        $this->assertInternalType( 'array', $response );
    2727
    28         $this->assertEquals( 'image/jpeg', $headers['content-type'] );
    29         $this->assertEquals( '40148', $headers['content-length'] );
    30         $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
     28        $this->assertSame( 'image/png', $headers['Content-Type'] );
     29        $this->assertSame( '153204', $headers['Content-Length'] );
     30        $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    3131    }
    3232
    3333    function test_head_redirect() {
    3434        // This URL will 301 redirect.
    35         $url      = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     35        $url      = 'https://wp.org/screenshots/3.9/dashboard.png';
    3636        $response = wp_remote_head( $url );
    3737
     
    4040    }
    4141
    42     function test_head_404() {
    43         $url      = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
     42    /**
     43     * @covers ::wp_remote_head
     44     */
     45    public function test_head_404() {
     46        $url      = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg';
    4447        $response = wp_remote_head( $url );
    4548
     
    4851    }
    4952
    50     function test_get_request() {
    51         $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     53    /**
     54     * @covers ::wp_remote_get
     55     * @covers ::wp_remote_retrieve_headers
     56     * @covers ::wp_remote_retrieve_response_code
     57     */
     58    public function test_get_request() {
     59        $url = 'https://s.w.org/screenshots/3.9/dashboard.png';
    5260
    5361        $response = wp_remote_get( $url );
     
    6068
    6169        // Should return the same headers as a HEAD request.
    62         $this->assertEquals( 'image/jpeg', $headers['content-type'] );
    63         $this->assertEquals( '40148', $headers['content-length'] );
    64         $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
     70        $this->assertSame( 'image/png', $headers['Content-Type'] );
     71        $this->assertSame( '153204', $headers['Content-Length'] );
     72        $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    6573    }
    6674
    6775    function test_get_redirect() {
    68         // This will redirect to asdftestblog1.files.wordpress.com.
    69         $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     76        // This will redirect to wordpress.org.
     77        $url = 'https://wp.org/screenshots/3.9/dashboard.png';
    7078
    7179        $response = wp_remote_get( $url );
     
    7684
    7785        // Should return the same headers as a HEAD request.
    78         $this->assertEquals( 'image/jpeg', $headers['content-type'] );
    79         $this->assertEquals( '40148', $headers['content-length'] );
    80         $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
     86        $this->assertSame( 'image/png', $headers['Content-Type'] );
     87        $this->assertSame( '153204', $headers['Content-Length'] );
     88        $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    8189    }
    8290
    8391    function test_get_redirect_limit_exceeded() {
    84         // This will redirect to asdftestblog1.files.wordpress.com.
    85         $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     92        // This will redirect to wordpress.org.
     93        $url = 'https://wp.org/screenshots/3.9/dashboard.png';
    8694
    8795        // Pretend we've already redirected 5 times.
  • branches/5.5/tests/phpunit/tests/image/functions.php

    r48464 r57996  
    336336
    337337        $file = wp_crop_image(
    338             'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
     338            'https://s.w.org/screenshots/3.9/dashboard.png',
    339339            0,
    340340            0,
     
    344344            100,
    345345            false,
    346             DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg'
     346            DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png'
    347347        );
    348348
     
    380380
    381381        $file = wp_crop_image(
    382             'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
     382            'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg',
    383383            0,
    384384            0,
Note: See TracChangeset for help on using the changeset viewer.