Make WordPress Core


Ignore:
Timestamp:
01/30/2021 11:45:38 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use skipTestOnTimeout() in more HTTP tests.

Adjust it to handle more types of timeouts, e.g. "Resolving timed out", "Connection timed out".

Merges [38757], [43511], [43512], [46682], [46996] to the 4.6 branch.
See #51669.

Location:
branches/4.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

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

    r38164 r50089  
    66 */
    77class Tests_HTTP_Functions extends WP_UnitTestCase {
     8
    89    public function setUp() {
    910        if ( ! extension_loaded( 'openssl' ) ) {
     
    1819        $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
    1920        $response = wp_remote_head( $url );
     21
     22        $this->skipTestOnTimeout( $response );
     23
    2024        $headers = wp_remote_retrieve_headers( $response );
    2125
     
    3842        $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
    3943        $response = wp_remote_head( $url );
     44
     45        $this->skipTestOnTimeout( $response );
    4046        $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) );
    4147    }
     
    4349    function test_head_404() {
    4450        $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
    45         $headers = wp_remote_head( $url );
     51        $response = wp_remote_head( $url );
    4652
    47         $this->assertEquals( '404', wp_remote_retrieve_response_code( $headers ) );
     53        $this->skipTestOnTimeout( $response );
     54        $this->assertEquals( '404', wp_remote_retrieve_response_code( $response ) );
    4855    }
    4956
     
    5259
    5360        $response = wp_remote_get( $url );
     61
     62        $this->skipTestOnTimeout( $response );
     63
    5464        $headers = wp_remote_retrieve_headers( $response );
    5565
     
    6575
    6676        $response = wp_remote_get( $url );
     77
     78        $this->skipTestOnTimeout( $response );
     79
    6780        $headers = wp_remote_retrieve_headers( $response );
    6881
     
    7992        // pretend we've already redirected 5 times
    8093        $response = wp_remote_get( $url, array( 'redirection' => -1 ) );
     94
     95        $this->skipTestOnTimeout( $response );
    8196        $this->assertWPError( $response );
    8297    }
     
    89104
    90105        $response = wp_remote_head( $url );
    91         $cookies  = wp_remote_retrieve_cookies( $response );
     106
     107        $this->skipTestOnTimeout( $response );
     108
     109        $cookies = wp_remote_retrieve_cookies( $response );
    92110
    93111        $this->assertNotEmpty( $cookies );
     
    119137            ),
    120138        ) );
    121         $cookies  = wp_remote_retrieve_cookies( $response );
     139
     140        $this->skipTestOnTimeout( $response );
     141
     142        $cookies = wp_remote_retrieve_cookies( $response );
    122143
    123144        $this->assertNotEmpty( $cookies );
     
    140161            ),
    141162        ) );
    142         $cookies  = wp_remote_retrieve_cookies( $response );
     163
     164        $this->skipTestOnTimeout( $response );
     165
     166        $cookies = wp_remote_retrieve_cookies( $response );
    143167
    144168        $this->assertNotEmpty( $cookies );
Note: See TracChangeset for help on using the changeset viewer.