Make WordPress Core


Ignore:
Timestamp:
01/30/2021 12:04:12 PM (3 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.5 branch.
See #51669.

Location:
branches/4.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.5

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

    r35734 r50090  
    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
     
    3034        $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
    3135        $response = wp_remote_head( $url );
     36
     37        $this->skipTestOnTimeout( $response );
    3238        $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) );
    3339    }
     
    3541    function test_head_404() {
    3642        $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
    37         $headers = wp_remote_head( $url );
     43        $response = wp_remote_head( $url );
    3844
    39         $this->assertInternalType( 'array', $headers, "Reply wasn't array." );
    40         $this->assertEquals( '404', wp_remote_retrieve_response_code( $headers ) );
     45        $this->skipTestOnTimeout( $response );
     46        $this->assertInternalType( 'array', $response, "Reply wasn't array." );
     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
     
    5969
    6070        $response = wp_remote_get( $url );
     71
     72        $this->skipTestOnTimeout( $response );
     73
    6174        $headers = wp_remote_retrieve_headers( $response );
    6275
     
    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->assertInternalType( 'array', $cookies );
Note: See TracChangeset for help on using the changeset viewer.