diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index 248aaa833a..c18c4d434f 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -302,36 +302,38 @@ class Tests_Theme extends WP_UnitTestCase { /** * @ticket 48566 + * + * @dataProvider data_year_in_readme */ - public function test_year_in_readme() { + public function test_year_in_readme( $theme ) { // This test is designed to only run on trunk. $this->skipOnAutomatedBranches(); - foreach ( $this->default_themes as $theme ) { - $wp_theme = wp_get_theme( $theme ); + $wp_theme = wp_get_theme( $theme ); - $path_to_readme_txt = $wp_theme->get_theme_root() . '/' . $wp_theme->get_stylesheet() . '/readme.txt'; - $this->assertFileExists( $path_to_readme_txt ); + $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' ); + $readme = file_get_contents( $path_to_readme_txt ); + $this_year = gmdate( 'Y' ); - preg_match( '#Copyright (\d+) WordPress.org#', $readme, $matches ); - if ( $matches ) { - $readme_year = trim( $matches[1] ); + preg_match( '#(Copyright|\(C\)) (20\d\d-)?(\d+) WordPress.org#i', $readme, $matches ); + if ( $matches ) { + $readme_year = trim( $matches[3] ); - $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 ) { - $readme_year = trim( $matches[1] ); - - $this->assertSame( $this_year, $readme_year, "Bundled themes readme.txt's year needs to be updated to $this_year." ); - } + $this->assertSame( $this_year, $readme_year, "$theme readme.txt's year needs to be updated to $this_year." ); } } + public function data_year_in_readme() { + return array_map( + static function ( $theme ) { + return array( $theme ); + }, + $this->default_themes + ); + } + /** * @ticket 20897 * @expectedDeprecated get_theme_data