\s*| \s*]*>\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 version ([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 );
$this_year = date( 'Y' );
$this->assertEquals( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." );
}
function test_package_json() {
$package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' );
$package_json = json_decode( $package_json, true );
list( $version ) = explode( '-', $GLOBALS['wp_version'] );
// package.json uses x.y.z, so fill cleaned $wp_version for .0 releases
if ( 1 == substr_count( $version, '.' ) ) {
$version .= '.0';
}
$this->assertEquals( $version, $package_json['version'], "package.json's version needs to be updated to $version." );
}
// two tests for a lame bug in PHPUnit that broke the $GLOBALS reference
function test_globals() {
global $test_foo;
$test_foo = array('foo', 'bar', 'baz');
function test_globals_foo() {
unset($GLOBALS['test_foo'][1]);
}
test_globals_foo();
$this->assertEquals($test_foo, array(0=>'foo', 2=>'baz'));
$this->assertEquals($test_foo, $GLOBALS['test_foo']);
}
function test_globals_bar() {
global $test_bar;
$test_bar = array('a', 'b', 'c');
$this->assertEquals($test_bar, $GLOBALS['test_bar']);
}
// test some helper utility functions
function test_strip_ws() {
$this->assertEquals('', strip_ws(''));
$this->assertEquals('foo', strip_ws('foo'));
$this->assertEquals('', strip_ws("\r\n\t \n\r\t"));
$in = "asdf\n";
$in .= "asdf asdf\n";
$in .= "asdf asdf\n";
$in .= "\tasdf\n";
$in .= "\tasdf\t\n";
$in .= "\t\tasdf\n";
$in .= "foo bar\n\r\n";
$in .= "foo\n";
$expected = "asdf\n";
$expected .= "asdf asdf\n";
$expected .= "asdf asdf\n";
$expected .= "asdf\n";
$expected .= "asdf\n";
$expected .= "asdf\n";
$expected .= "foo bar\n";
$expected .= "foo";
$this->assertEquals($expected, strip_ws($in));
}
function test_mask_input_value() {
$in = <<Assign Authors
To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as admins entries.
If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)
|