WordPress.org

Make WordPress Core

Changeset 35172


Ignore:
Timestamp:
10/15/2015 12:22:50 AM (5 years ago)
Author:
wonderboymusic
Message:

Unit Tests: move ->test_readme() out of Tests_Basic and into Tests_External_HTTP_Basic in tests/external-http/.

I intend to move other wp_remote_get() tests into similar classes.

See #30017, #33968.

Location:
trunk/tests/phpunit/tests
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/basic.php

    r33946 r35172  
    2020    function test_true() {
    2121        $this->assertTrue($this->val);
    22     }
    23 
    24     function test_readme() {
    25         $readme = file_get_contents( ABSPATH . 'readme.html' );
    26         preg_match( '#<br /> Version (.*)#', $readme, $matches );
    27         list( $version ) = explode( '-', $GLOBALS['wp_version'] );
    28         $this->assertEquals( $version, trim( $matches[1] ), "readme.html's version needs to be updated to $version." );
    29 
    30         preg_match( '#Recommendations.*PHP</a> version <strong>([0-9.]*)#s', $readme, $matches );
    31 
    32         $response = wp_remote_get( 'https://secure.php.net/supported-versions.php' );
    33         if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
    34             $this->markTestSkipped( 'Could not contact PHP.net to check versions.' );
    35         }
    36         $php = wp_remote_retrieve_body( $response );
    37 
    38         preg_match_all( '#<tr class="stable">\s*<td>\s*<a [^>]*>\s*([0-9.]*)#s', $php, $phpmatches );
    39 
    40         $this->assertContains( $matches[1], $phpmatches[1], "readme.html's Recommended PHP version is too old. Remember to update the WordPress.org Requirements page, too." );
    41 
    42         preg_match( '#Recommendations.*MySQL</a> version <strong>([0-9.]*)#s', $readme, $matches );
    43 
    44         $response = wp_remote_get( "https://dev.mysql.com/doc/relnotes/mysql/{$matches[1]}/en/" );
    45         if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
    46             $this->markTestSkipped( 'Could not contact dev.MySQL.com to check versions.' );
    47         }
    48         $mysql = wp_remote_retrieve_body( $response );
    49 
    50         preg_match( '#(\d{4}-\d{2}-\d{2}), General Availability#', $mysql, $mysqlmatches );
    51 
    52         // Per https://www.mysql.com/support/, Oracle actively supports MySQL releases for 5 years from GA release
    53         $mysql_eol = strtotime( $mysqlmatches[1] . ' +5 years' );
    54 
    55         $this->assertLessThan( $mysql_eol, time(), "readme.html's Recommended MySQL version is too old. Remember to update the WordPress.org Requirements page, too." );
    5622    }
    5723
Note: See TracChangeset for help on using the changeset viewer.