Changeset 47122 for trunk/tests/phpunit/tests/theme.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme.php
r46719 r47122 92 92 $this->assertFalse( $theme->errors() ); 93 93 $_theme = wp_get_theme( $theme->get_stylesheet() ); 94 // This primes internal WP_Theme caches for the next assertion (headers_sanitized, textdomain_loaded) 94 // This primes internal WP_Theme caches for the next assertion (headers_sanitized, textdomain_loaded). 95 95 $this->assertEquals( $theme->get( 'Name' ), $_theme->get( 'Name' ) ); 96 96 $this->assertEquals( $theme, $_theme ); … … 103 103 function test_get_themes_contents() { 104 104 $themes = get_themes(); 105 // Generic tests that should hold true for any theme 105 // Generic tests that should hold true for any theme. 106 106 foreach ( $themes as $k => $theme ) { 107 107 // Don't run these checks for custom themes. … … 113 113 $this->assertNotEmpty( $theme['Title'] ); 114 114 115 // important attributes should all be set115 // Important attributes should all be set. 116 116 $default_headers = array( 117 117 'Title' => 'Theme Title', … … 126 126 'Author' => 'Author', 127 127 'Tags' => 'Tags', 128 // Introduced in WordPress 2.9 128 // Introduced in WordPress 2.9. 129 129 'Theme Root' => 'Theme Root', 130 130 'Theme Root URI' => 'Theme Root URI', … … 134 134 } 135 135 136 // Make the tests work both for WordPress 2.8.5 and WordPress 2.9-rare 136 // Make the tests work both for WordPress 2.8.5 and WordPress 2.9-rare. 137 137 $dir = isset( $theme['Theme Root'] ) ? '' : WP_CONTENT_DIR; 138 138 139 // important attributes should all not be empty as well139 // Important attributes should all not be empty as well. 140 140 $this->assertNotEmpty( $theme['Description'] ); 141 141 $this->assertNotEmpty( $theme['Author'] ); … … 144 144 $this->assertNotEmpty( $theme['Stylesheet'] ); 145 145 146 // template files should all exist146 // Template files should all exist. 147 147 $this->assertTrue( is_array( $theme['Template Files'] ) ); 148 148 $this->assertTrue( count( $theme['Template Files'] ) > 0 ); … … 152 152 } 153 153 154 // css files should all exist154 // CSS files should all exist. 155 155 $this->assertTrue( is_array( $theme['Stylesheet Files'] ) ); 156 156 $this->assertTrue( count( $theme['Stylesheet Files'] ) > 0 ); … … 271 271 for ( $i = 0; $i < 3; $i++ ) { 272 272 foreach ( $themes as $name => $theme ) { 273 // switch to this theme273 // Switch to this theme. 274 274 if ( 2 === $i ) { 275 275 switch_theme( $theme['Template'], $theme['Stylesheet'] ); … … 280 280 $this->assertEquals( $name, get_current_theme() ); 281 281 282 // make sure the various get_* functions return the correct values282 // Make sure the various get_* functions return the correct values. 283 283 $this->assertEquals( $theme['Template'], get_template() ); 284 284 $this->assertEquals( $theme['Stylesheet'], get_stylesheet() ); … … 293 293 $this->assertEquals( $root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri() ); 294 294 $this->assertEquals( $root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri() ); 295 # $this->assertEquals($root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri());295 // $this->assertEquals( $root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri() ); 296 296 297 297 $this->assertEquals( $root_fs . '/' . get_template(), get_template_directory() ); 298 298 $this->assertEquals( $root_uri . '/' . get_template(), get_template_directory_uri() ); 299 299 300 // get_query_template301 302 // template file that doesn't exist300 // get_query_template() 301 302 // Template file that doesn't exist. 303 303 $this->assertEquals( '', get_query_template( rand_str() ) ); 304 304 305 // template files that do exist 306 //foreach ($theme['Template Files'] as $path) { 307 //$file = basename($path, '.php'); 308 // FIXME: untestable because get_query_template uses TEMPLATEPATH 309 //$this->assertEquals('', get_query_template($file)); 310 //} 311 312 // these are kind of tautologies but at least exercise the code 305 // Template files that do exist. 306 /* 307 foreach ( $theme['Template Files'] as $path ) { 308 $file = basename($path, '.php'); 309 FIXME: untestable because get_query_template() uses TEMPLATEPATH. 310 $this->assertEquals('', get_query_template($file)); 311 } 312 */ 313 314 // These are kind of tautologies but at least exercise the code. 313 315 $this->assertEquals( get_404_template(), get_query_template( '404' ) ); 314 316 $this->assertEquals( get_archive_template(), get_query_template( 'archive' ) ); … … 325 327 $this->assertEquals( get_tag_template(), get_query_template( 'tag' ) ); 326 328 327 // nb: this probably doesn't run because WP_INSTALLING is defined329 // nb: This probably doesn't run because WP_INSTALLING is defined. 328 330 $this->assertTrue( validate_current_theme() ); 329 331 } … … 332 334 333 335 function test_switch_theme_bogus() { 334 // try switching to a theme that doesn't exist336 // Try switching to a theme that doesn't exist. 335 337 $template = rand_str(); 336 338 $style = rand_str(); … … 343 345 $this->assertFalse( $theme->exists() ); 344 346 345 // these return the bogus name - perhaps not ideal behaviour?347 // These return the bogus name - perhaps not ideal behaviour? 346 348 $this->assertEquals( $template, get_template() ); 347 349 $this->assertEquals( $style, get_stylesheet() ); … … 371 373 do_action( 'customize_register', $wp_customize ); 372 374 373 // The post_date for auto-drafts is bumped to match the changeset post_date whenever it is modified to keep them from from being garbage collected by wp_delete_auto_drafts(). 375 // The post_date for auto-drafts is bumped to match the changeset post_date whenever it is modified 376 // to keep them from from being garbage collected by wp_delete_auto_drafts(). 374 377 $wp_customize->save_changeset_post( 375 378 array(
Note: See TracChangeset
for help on using the changeset viewer.