Changeset 59186
- Timestamp:
- 10/07/2024 12:35:43 AM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme.php
r59150 r59186 213 213 } 214 214 215 /** 216 * Tests the default themes list in the test suite matches the runtime default themes. 217 */ 218 public function test_default_default_theme_list_match_in_test_suite_and_at_runtime() { 219 // Use a reflection to make WP_THEME::$default_themes accessible. 220 $reflection = new ReflectionClass( 'WP_Theme' ); 221 $property = $reflection->getProperty( 'default_themes' ); 222 $property->setAccessible( true ); 223 224 /* 225 * `default` and `classic` are included in `WP_Theme::$default_themes` but not included 226 * in the test suite default themes list. These are excluded from the comparison. 227 */ 228 $default_themes = array_keys( $property->getValue() ); 229 $default_themes = array_diff( $default_themes, array( 'default', 'classic' ) ); 230 231 $this->assertSameSets( $default_themes, $this->default_themes, 'Test suite default themes should match the runtime default themes.' ); 232 } 233 234 /** 235 * Test the default theme in WP_Theme matches the WP_DEFAULT_THEME constant. 236 */ 237 public function test_default_theme_matches_constant() { 238 $latest_default_theme = WP_Theme::get_core_default_theme(); 239 240 /* 241 * The test suite sets the constant to `default` while this is intended to 242 * test the value defined in default-constants.php. 243 * 244 * Therefore this reads the file in via file_get_contents to extract the value. 245 */ 246 $default_constants = file_get_contents( ABSPATH . WPINC . '/default-constants.php' ); 247 preg_match( '/define\( \'WP_DEFAULT_THEME\', \'(.*)\' \);/', $default_constants, $matches ); 248 $wp_default_theme_constant = $matches[1]; 249 250 $this->assertSame( $wp_default_theme_constant, $latest_default_theme->get_stylesheet(), 'WP_DEFAULT_THEME should match the latest default theme.' ); 251 } 252 215 253 public function test_default_themes_have_textdomain() { 216 254 foreach ( $this->default_themes as $theme ) {
Note: See TracChangeset
for help on using the changeset viewer.