Skip to content

Commit

Permalink
Bundled Themes: Test new themes are added to new bundled files.
Browse files Browse the repository at this point in the history
Introduces a test to ensure that new bundled themes are included in the `$_new_bundled_files` array. Modifies previous theme related tests added during the 6.7 release cycle to include the correct annotations.

Props peterwilsoncc, mukesh27, costdev.
See #61530, #62103.


git-svn-id: https://develop.svn.wordpress.org/trunk@59227 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
peterwilsoncc committed Oct 14, 2024
1 parent 649efd0 commit 1dcbe10
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/phpunit/tests/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public function test_default_theme_in_default_theme_list() {

/**
* Tests the default themes list in the test suite matches the runtime default themes.
*
* @ticket 62103
*
* @coversNothing
*/
public function test_default_default_theme_list_match_in_test_suite_and_at_runtime() {
// Use a reflection to make WP_THEME::$default_themes accessible.
Expand All @@ -233,6 +237,10 @@ public function test_default_default_theme_list_match_in_test_suite_and_at_runti

/**
* Test the default theme in WP_Theme matches the WP_DEFAULT_THEME constant.
*
* @ticket 62103
*
* @covers WP_Theme::get_core_default_theme
*/
public function test_default_theme_matches_constant() {
$latest_default_theme = WP_Theme::get_core_default_theme();
Expand All @@ -250,6 +258,40 @@ public function test_default_theme_matches_constant() {
$this->assertSame( $wp_default_theme_constant, $latest_default_theme->get_stylesheet(), 'WP_DEFAULT_THEME should match the latest default theme.' );
}

/**
* Ensure that the default themes are included in the new bundled files.
*
* @ticket 62103
*
* @coversNothing
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function test_default_themes_are_included_in_new_files() {
require_once ABSPATH . 'wp-admin/includes/update-core.php';
global $_new_bundled_files;
// Limit new bundled files to the default themes.
$new_theme_files = array_keys( $_new_bundled_files );
$new_theme_files = array_filter(
$new_theme_files,
static function ( $file ) {
return str_starts_with( $file, 'themes/' );
}
);

$tested_themes = $this->default_themes;
// Convert the tested themes to directory names.
$tested_themes = array_map(
static function ( $theme ) {
return "themes/{$theme}/";
},
$tested_themes
);

$this->assertSameSets( $tested_themes, $new_theme_files, 'New bundled files should include the default themes.' );
}

public function test_default_themes_have_textdomain() {
foreach ( $this->default_themes as $theme ) {
if ( wp_get_theme( $theme )->exists() ) {
Expand Down

0 comments on commit 1dcbe10

Please sign in to comment.