diff --git a/tests/phpunit/tests/basic.php b/tests/phpunit/tests/basic.php index 1a9e189ca3..31b79b7937 100644 --- a/tests/phpunit/tests/basic.php +++ b/tests/phpunit/tests/basic.php @@ -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; } diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index 14eccdf6da..f6a418d3d3 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -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." ); } } }