Changeset 56635 for trunk/tests/phpunit/tests/template.php
- Timestamp:
- 09/20/2023 05:25:26 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/template.php
r56547 r56635 628 628 ), 629 629 ); 630 } 631 632 /** 633 * Tests that `locate_template()` uses the current theme even after switching the theme. 634 * 635 * @ticket 18298 636 * 637 * @covers ::locate_template 638 */ 639 public function test_locate_template_uses_current_theme() { 640 $themes = wp_get_themes(); 641 642 // Look for parent themes with an index.php template. 643 $relevant_themes = array(); 644 foreach ( $themes as $theme ) { 645 if ( $theme->get_stylesheet() !== $theme->get_template() ) { 646 continue; 647 } 648 $php_templates = $theme['Template Files']; 649 if ( ! isset( $php_templates['index.php'] ) ) { 650 continue; 651 } 652 $relevant_themes[] = $theme; 653 } 654 if ( count( $relevant_themes ) < 2 ) { 655 $this->markTestSkipped( 'Test requires at least two parent themes with an index.php template.' ); 656 } 657 658 $template_names = array( 'index.php' ); 659 660 $old_theme = $relevant_themes[0]; 661 $new_theme = $relevant_themes[1]; 662 663 switch_theme( $old_theme->get_stylesheet() ); 664 $this->assertSame( $old_theme->get_stylesheet_directory() . '/index.php', locate_template( $template_names ), 'Incorrect index template found in initial theme.' ); 665 666 switch_theme( $new_theme->get_stylesheet() ); 667 $this->assertSame( $new_theme->get_stylesheet_directory() . '/index.php', locate_template( $template_names ), 'Incorrect index template found in theme after switch.' ); 630 668 } 631 669
Note: See TracChangeset
for help on using the changeset viewer.