Make WordPress Core

Changeset 46998


Ignore:
Timestamp:
12/19/2019 08:27:16 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Skip external HTTP test for recommended PHP and MySQL versions on 503 errors.

Fixes #49049.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/external-http/basic.php

    r46996 r46998  
    66
    77    function test_readme() {
    8         // This test is designed to only run on trunk/master
     8        // This test is designed to only run on trunk/master.
    99        $this->skipOnAutomatedBranches();
    1010
     
    1313        preg_match( '#Recommendations.*PHP</a> version <strong>([0-9.]*)#s', $readme, $matches );
    1414
    15         $response = wp_remote_get( 'https://secure.php.net/supported-versions.php' );
     15        $response = wp_remote_get( 'https://www.php.net/supported-versions.php' );
    1616
    1717        $this->skipTestOnTimeout( $response );
    1818
    1919        $response_code = wp_remote_retrieve_response_code( $response );
     20        $response_body = wp_remote_retrieve_body( $response );
     21
    2022        if ( 200 !== $response_code ) {
    21             $this->fail( sprintf( 'Could not contact PHP.net to check versions. Response code: %s', $response_code ) );
     23            $error_message = sprintf(
     24                'Could not contact PHP.net to check versions. Response code: %s. Response body: %s',
     25                $response_code,
     26                $response_body
     27            );
     28
     29            if ( 503 === $response_code ) {
     30                $this->markTestSkipped( $error_message );
     31            }
     32
     33            $this->fail( $error_message );
    2234        }
    2335
    24         $php = wp_remote_retrieve_body( $response );
    25 
    26         preg_match_all( '#<tr class="stable">\s*<td>\s*<a [^>]*>\s*([0-9.]*)#s', $php, $phpmatches );
     36        preg_match_all( '#<tr class="stable">\s*<td>\s*<a [^>]*>\s*([0-9.]*)#s', $response_body, $phpmatches );
    2737
    2838        $this->assertContains( $matches[1], $phpmatches[1], "readme.html's Recommended PHP version is too old. Remember to update the WordPress.org Requirements page, too." );
     
    3545
    3646        $response_code = wp_remote_retrieve_response_code( $response );
     47        $response_body = wp_remote_retrieve_body( $response );
     48
    3749        if ( 200 !== $response_code ) {
    38             $this->fail( sprintf( 'Could not contact dev.MySQL.com to check versions. Response code: %s', $response_code ) );
     50            $error_message = sprintf(
     51                'Could not contact dev.MySQL.com to check versions. Response code: %s. Response body: %s',
     52                $response_code,
     53                $response_body
     54            );
     55
     56            if ( 503 === $response_code ) {
     57                $this->markTestSkipped( $error_message );
     58            }
     59
     60            $this->fail( $error_message );
    3961        }
    4062
    41         $mysql = wp_remote_retrieve_body( $response );
    42 
    43         preg_match( '#(\d{4}-\d{2}-\d{2}), General Availability#', $mysql, $mysqlmatches );
     63        preg_match( '#(\d{4}-\d{2}-\d{2}), General Availability#', $response_body, $mysqlmatches );
    4464
    4565        // Per https://www.mysql.com/support/, Oracle actively supports MySQL releases for 5 years from GA release
Note: See TracChangeset for help on using the changeset viewer.