Make WordPress Core

Changeset 57995


Ignore:
Timestamp:
04/15/2024 12:27:18 PM (2 weeks 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:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r49006 r57995  
    2727    public function test_wp_remote_fopen() {
    2828        // This URL gives a direct 200 response.
    29         $url      = 'https://asdftestblog1.files.wordpress.com/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->assertInternalType( 'string', $response );
    33         $this->assertSame( 40148, strlen( $response ) );
     33        $this->assertSame( 153204, strlen( $response ) );
    3434    }
    3535}
  • 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.
  • branches/5.6/tests/phpunit/tests/image/functions.php

    r49450 r57995  
    369369    public function test_wp_crop_image_url() {
    370370        $file = wp_crop_image(
    371             'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
     371            'https://s.w.org/screenshots/3.9/dashboard.png',
    372372            0,
    373373            0,
     
    377377            100,
    378378            false,
    379             DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg'
     379            DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png'
    380380        );
    381381
     
    412412    public function test_wp_crop_image_url_not_exist() {
    413413        $file = wp_crop_image(
    414             'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
     414            'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg',
    415415            0,
    416416            0,
Note: See TracChangeset for help on using the changeset viewer.