Make WordPress Core


Ignore:
Timestamp:
01/30/2021 11:13:04 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 [43511], [43512], [46682], [46996] to the 4.8 branch.
See #51669.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

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

    r38761 r50087  
    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
     
    3135        $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
    3236        $response = wp_remote_head( $url );
     37
     38        $this->skipTestOnTimeout( $response );
    3339        $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) );
    3440    }
     
    3642    function test_head_404() {
    3743        $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
    38         $headers = wp_remote_head( $url );
     44        $response = wp_remote_head( $url );
    3945
    40         $this->assertEquals( '404', wp_remote_retrieve_response_code( $headers ) );
     46        $this->skipTestOnTimeout( $response );
     47        $this->assertEquals( '404', wp_remote_retrieve_response_code( $response ) );
    4148    }
    4249
     
    4552
    4653        $response = wp_remote_get( $url );
     54
     55        $this->skipTestOnTimeout( $response );
     56
    4757        $headers = wp_remote_retrieve_headers( $response );
    4858
     
    6070
    6171        $response = wp_remote_get( $url );
     72
     73        $this->skipTestOnTimeout( $response );
     74
    6275        $headers = wp_remote_retrieve_headers( $response );
    6376
     
    7487        // pretend we've already redirected 5 times
    7588        $response = wp_remote_get( $url, array( 'redirection' => -1 ) );
     89
     90        $this->skipTestOnTimeout( $response );
    7691        $this->assertWPError( $response );
    7792    }
     
    8499
    85100        $response = wp_remote_head( $url );
    86         $cookies  = wp_remote_retrieve_cookies( $response );
     101
     102        $this->skipTestOnTimeout( $response );
     103
     104        $cookies = wp_remote_retrieve_cookies( $response );
    87105
    88106        $this->assertNotEmpty( $cookies );
     
    114132            ),
    115133        ) );
    116         $cookies  = wp_remote_retrieve_cookies( $response );
     134
     135        $this->skipTestOnTimeout( $response );
     136
     137        $cookies = wp_remote_retrieve_cookies( $response );
    117138
    118139        $this->assertNotEmpty( $cookies );
     
    135156            ),
    136157        ) );
    137         $cookies  = wp_remote_retrieve_cookies( $response );
     158
     159        $this->skipTestOnTimeout( $response );
     160
     161        $cookies = wp_remote_retrieve_cookies( $response );
    138162
    139163        $this->assertNotEmpty( $cookies );
Note: See TracChangeset for help on using the changeset viewer.