mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Improve the logic of the SECURITY.md test to check all supported versions.
This avoids a test failure if the list of supported WordPress versions is updated before the trunk version is bumped for a new major release. Follow-up to [47403], [53347]. Fixes #55667. git-svn-id: https://develop.svn.wordpress.org/trunk@53357 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
62040b8b9d
commit
7f0758ec02
@ -13,8 +13,10 @@ class Tests_Basic extends WP_UnitTestCase {
|
||||
|
||||
$license = file_get_contents( ABSPATH . 'license.txt' );
|
||||
preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches );
|
||||
$this_year = gmdate( 'Y' );
|
||||
$this->assertSame( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." );
|
||||
$license_year = trim( $matches[1] );
|
||||
$this_year = gmdate( 'Y' );
|
||||
|
||||
$this->assertSame( $this_year, $license_year, "license.txt's year needs to be updated to $this_year." );
|
||||
}
|
||||
|
||||
public function test_security_md() {
|
||||
@ -22,21 +24,26 @@ class Tests_Basic extends WP_UnitTestCase {
|
||||
$this->skipOnAutomatedBranches();
|
||||
|
||||
$security = file_get_contents( dirname( ABSPATH ) . '/SECURITY.md' );
|
||||
preg_match( '#\d.\d.x#', $security, $matches );
|
||||
$current_version = substr( $GLOBALS['wp_version'], 0, 3 );
|
||||
$latest_stable = number_format( (float) $current_version - 0.1, 1 ) . '.x';
|
||||
$this->assertSame( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." );
|
||||
preg_match_all( '#\d.\d.x#', $security, $matches );
|
||||
$supported_versions = $matches[0];
|
||||
$current_version = substr( $GLOBALS['wp_version'], 0, 3 );
|
||||
$latest_stable = number_format( (float) $current_version - 0.1, 1 ) . '.x';
|
||||
|
||||
$this->assertContains( $latest_stable, $supported_versions, "SECURITY.md's version needs to be updated to $latest_stable." );
|
||||
}
|
||||
|
||||
public 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->assertSame( $version, $package_json['version'], "package.json's version needs to be updated to $version." );
|
||||
|
||||
return $package_json;
|
||||
}
|
||||
|
||||
|
||||
@ -221,17 +221,22 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
|
||||
$path_to_readme_txt = $wp_theme->get_theme_root() . '/' . $wp_theme->get_stylesheet() . '/readme.txt';
|
||||
$this->assertFileExists( $path_to_readme_txt );
|
||||
|
||||
$readme = file_get_contents( $path_to_readme_txt );
|
||||
$this_year = gmdate( 'Y' );
|
||||
|
||||
preg_match( '#Copyright (\d+) WordPress.org#', $readme, $matches );
|
||||
if ( $matches ) {
|
||||
$this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." );
|
||||
$readme_year = trim( $matches[1] );
|
||||
|
||||
$this->assertSame( $this_year, $readme_year, "Bundled themes readme.txt's year needs to be updated to $this_year." );
|
||||
}
|
||||
|
||||
preg_match( '#Copyright 20\d\d-(\d+) WordPress.org#', $readme, $matches );
|
||||
if ( $matches ) {
|
||||
$this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." );
|
||||
$readme_year = trim( $matches[1] );
|
||||
|
||||
$this->assertSame( $this_year, $readme_year, "Bundled themes readme.txt's year needs to be updated to $this_year." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user