Make WordPress Core

Changeset 57942 for branches/6.0


Ignore:
Timestamp:
04/07/2024 09:49:23 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 6.0 branch.

Props peterwilsoncc, jorbin.
See #60865.

Location:
branches/6.0
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

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

    r51331 r57942  
    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->assertIsString( $response );
    33                 $this->assertSame( 40148, strlen( $response ) );
     33                $this->assertSame( 153204, strlen( $response ) );
    3434        }
    3535}
  • branches/6.0/tests/phpunit/tests/http/functions.php

    r52328 r57942  
    1212        public function test_head_request() {
    1313                // This URL gives a direct 200 response.
    14                 $url      = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     14                $url      = 'https://s.w.org/screenshots/3.9/dashboard.png';
    1515                $response = wp_remote_head( $url );
    1616
    … …  
    2121                $this->assertIsArray( $response );
    2222
    23                 $this->assertSame( 'image/jpeg', $headers['content-type'] );
    24                 $this->assertSame( '40148', $headers['content-length'] );
     23                $this->assertSame( 'image/png', $headers['Content-Type'] );
     24                $this->assertSame( '153204', $headers['Content-Length'] );
    2525                $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    2626        }
    … …  
    3131        public function test_head_redirect() {
    3232                // This URL will 301 redirect.
    33                 $url      = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     33                $url      = 'https://wp.org/screenshots/3.9/dashboard.png';
    3434                $response = wp_remote_head( $url );
    3535
    … …  
    4242         */
    4343        public function test_head_404() {
    44                 $url      = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
     44                $url      = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg';
    4545                $response = wp_remote_head( $url );
    4646
    … …  
    5555         */
    5656        public function test_get_request() {
    57                 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     57                $url = 'https://s.w.org/screenshots/3.9/dashboard.png';
    5858
    5959                $response = wp_remote_get( $url );
    … …  
    6666
    6767                // Should return the same headers as a HEAD request.
    68                 $this->assertSame( 'image/jpeg', $headers['content-type'] );
    69                 $this->assertSame( '40148', $headers['content-length'] );
     68                $this->assertSame( 'image/png', $headers['Content-Type'] );
     69                $this->assertSame( '153204', $headers['Content-Length'] );
    7070                $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    7171        }
    … …  
    7777         */
    7878        public function test_get_redirect() {
    79                 // This will redirect to asdftestblog1.files.wordpress.com.
    80                 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     79                // This will redirect to wordpress.org.
     80                $url = 'https://wp.org/screenshots/3.9/dashboard.png';
    8181
    8282                $response = wp_remote_get( $url );
    … …  
    8787
    8888                // Should return the same headers as a HEAD request.
    89                 $this->assertSame( 'image/jpeg', $headers['content-type'] );
    90                 $this->assertSame( '40148', $headers['content-length'] );
     89                $this->assertSame( 'image/png', $headers['Content-Type'] );
     90                $this->assertSame( '153204', $headers['Content-Length'] );
    9191                $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    9292        }
    … …  
    9696         */
    9797        public function test_get_redirect_limit_exceeded() {
    98                 // This will redirect to asdftestblog1.files.wordpress.com.
    99                 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     98                // This will redirect to wordpress.org.
     99                $url = 'https://wp.org/screenshots/3.9/dashboard.png';
    100100
    101101                // Pretend we've already redirected 5 times.
  • branches/6.0/tests/phpunit/tests/image/functions.php

    r53292 r57942  
    393393        public function test_wp_crop_image_url() {
    394394                $file = wp_crop_image(
    395                         'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
     395                        'https://s.w.org/screenshots/3.9/dashboard.png',
    396396                        0,
    397397                        0,
    … …  
    401401                        100,
    402402                        false,
    403                         DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg'
     403                        DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png'
    404404                );
    405405
    … …  
    436436        public function test_wp_crop_image_url_not_exist() {
    437437                $file = wp_crop_image(
    438                         'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
     438                        'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg',
    439439                        0,
    440440                        0,
Note: See TracChangeset for help on using the changeset viewer.