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. git-svn-id: https://develop.svn.wordpress.org/trunk@35172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c1b2a034d3
commit
6f80581b80
@ -21,40 +21,6 @@ class Tests_Basic extends WP_UnitTestCase {
|
||||
$this->assertTrue($this->val);
|
||||
}
|
||||
|
||||
function test_readme() {
|
||||
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
||||
preg_match( '#<br /> Version (.*)#', $readme, $matches );
|
||||
list( $version ) = explode( '-', $GLOBALS['wp_version'] );
|
||||
$this->assertEquals( $version, trim( $matches[1] ), "readme.html's version needs to be updated to $version." );
|
||||
|
||||
preg_match( '#Recommendations.*PHP</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
||||
|
||||
$response = wp_remote_get( 'https://secure.php.net/supported-versions.php' );
|
||||
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
|
||||
$this->markTestSkipped( 'Could not contact PHP.net to check versions.' );
|
||||
}
|
||||
$php = wp_remote_retrieve_body( $response );
|
||||
|
||||
preg_match_all( '#<tr class="stable">\s*<td>\s*<a [^>]*>\s*([0-9.]*)#s', $php, $phpmatches );
|
||||
|
||||
$this->assertContains( $matches[1], $phpmatches[1], "readme.html's Recommended PHP version is too old. Remember to update the WordPress.org Requirements page, too." );
|
||||
|
||||
preg_match( '#Recommendations.*MySQL</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
||||
|
||||
$response = wp_remote_get( "https://dev.mysql.com/doc/relnotes/mysql/{$matches[1]}/en/" );
|
||||
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
|
||||
$this->markTestSkipped( 'Could not contact dev.MySQL.com to check versions.' );
|
||||
}
|
||||
$mysql = wp_remote_retrieve_body( $response );
|
||||
|
||||
preg_match( '#(\d{4}-\d{2}-\d{2}), General Availability#', $mysql, $mysqlmatches );
|
||||
|
||||
// Per https://www.mysql.com/support/, Oracle actively supports MySQL releases for 5 years from GA release
|
||||
$mysql_eol = strtotime( $mysqlmatches[1] . ' +5 years' );
|
||||
|
||||
$this->assertLessThan( $mysql_eol, time(), "readme.html's Recommended MySQL version is too old. Remember to update the WordPress.org Requirements page, too." );
|
||||
}
|
||||
|
||||
function test_license() {
|
||||
$license = file_get_contents( ABSPATH . 'license.txt' );
|
||||
preg_match( '#Copyright (\d+) by the contributors#', $license, $matches );
|
||||
|
40
tests/phpunit/tests/external-http/basic.php
Normal file
40
tests/phpunit/tests/external-http/basic.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @group external-http
|
||||
*/
|
||||
class Tests_External_HTTP_Basic extends WP_UnitTestCase {
|
||||
|
||||
function test_readme() {
|
||||
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
||||
preg_match( '#<br /> Version (.*)#', $readme, $matches );
|
||||
list( $version ) = explode( '-', $GLOBALS['wp_version'] );
|
||||
$this->assertEquals( $version, trim( $matches[1] ), "readme.html's version needs to be updated to $version." );
|
||||
|
||||
preg_match( '#Recommendations.*PHP</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
||||
|
||||
$response = wp_remote_get( 'https://secure.php.net/supported-versions.php' );
|
||||
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
|
||||
$this->markTestSkipped( 'Could not contact PHP.net to check versions.' );
|
||||
}
|
||||
$php = wp_remote_retrieve_body( $response );
|
||||
|
||||
preg_match_all( '#<tr class="stable">\s*<td>\s*<a [^>]*>\s*([0-9.]*)#s', $php, $phpmatches );
|
||||
|
||||
$this->assertContains( $matches[1], $phpmatches[1], "readme.html's Recommended PHP version is too old. Remember to update the WordPress.org Requirements page, too." );
|
||||
|
||||
preg_match( '#Recommendations.*MySQL</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
||||
|
||||
$response = wp_remote_get( "https://dev.mysql.com/doc/relnotes/mysql/{$matches[1]}/en/" );
|
||||
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
|
||||
$this->markTestSkipped( 'Could not contact dev.MySQL.com to check versions.' );
|
||||
}
|
||||
$mysql = wp_remote_retrieve_body( $response );
|
||||
|
||||
preg_match( '#(\d{4}-\d{2}-\d{2}), General Availability#', $mysql, $mysqlmatches );
|
||||
|
||||
// Per https://www.mysql.com/support/, Oracle actively supports MySQL releases for 5 years from GA release
|
||||
$mysql_eol = strtotime( $mysqlmatches[1] . ' +5 years' );
|
||||
|
||||
$this->assertLessThan( $mysql_eol, time(), "readme.html's Recommended MySQL version is too old. Remember to update the WordPress.org Requirements page, too." );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user