mirror of
git://develop.git.wordpress.org/
synced 2025-01-16 20:38:35 +01:00
Tests: Improve the test for the copyright year in bundled themes' readme.txt
.
This aims to catch entries like `(C) 2024 WordPress.org` in addition to `Copyright 2024 WordPress.org`. Includes converting the test to use a data provider, so that messages could be displayed for each individual theme. Follow-up to [46719], [59569]. See #62280. git-svn-id: https://develop.svn.wordpress.org/trunk@59579 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3a0717625f
commit
375af8c6c6
@ -302,36 +302,38 @@ class Tests_Theme extends WP_UnitTestCase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ticket 48566
|
* @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 test is designed to only run on trunk.
|
||||||
$this->skipOnAutomatedBranches();
|
$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';
|
$path_to_readme_txt = $wp_theme->get_theme_root() . '/' . $wp_theme->get_stylesheet() . '/readme.txt';
|
||||||
$this->assertFileExists( $path_to_readme_txt );
|
$this->assertFileExists( $path_to_readme_txt );
|
||||||
|
|
||||||
$readme = file_get_contents( $path_to_readme_txt );
|
$readme = file_get_contents( $path_to_readme_txt );
|
||||||
$this_year = gmdate( 'Y' );
|
$this_year = gmdate( 'Y' );
|
||||||
|
|
||||||
preg_match( '#Copyright (\d+) WordPress.org#', $readme, $matches );
|
preg_match( '#(Copyright|\(C\)) (20\d\d-)?(\d+) WordPress.org#i', $readme, $matches );
|
||||||
if ( $matches ) {
|
if ( $matches ) {
|
||||||
$readme_year = trim( $matches[1] );
|
$readme_year = trim( $matches[3] );
|
||||||
|
|
||||||
$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." );
|
||||||
}
|
|
||||||
|
|
||||||
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." );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function data_year_in_readme() {
|
||||||
|
return array_map(
|
||||||
|
static function ( $theme ) {
|
||||||
|
return array( $theme );
|
||||||
|
},
|
||||||
|
$this->default_themes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ticket 20897
|
* @ticket 20897
|
||||||
* @expectedDeprecated get_theme_data
|
* @expectedDeprecated get_theme_data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user