Skip to content

Commit f5f0366

Browse files
committed
Tests: Restore the original theme after position support tests.
Save the incoming stylesheet and restore it after resetting theme directories, removing fixture-root filters, and clearing theme caches. Developed in: #14877 Props shailu25. See #65893. git-svn-id: https://develop.svn.wordpress.org/trunk@64818 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3763040 commit f5f0366

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎tests/phpunit/tests/block-supports/wpRenderPositionSupport.php‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@ class Tests_Block_Supports_WpRenderPositionSupport extends WP_UnitTestCase {
2525
*/
2626
private $orig_theme_dir;
2727

28+
/**
29+
* Original stylesheet.
30+
*
31+
* @ticket 65893
32+
*
33+
* @var string
34+
*/
35+
private $original_stylesheet;
36+
2837
public function set_up() {
2938
parent::set_up();
30-
$this->test_block_name = null;
31-
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
32-
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
39+
$this->test_block_name = null;
40+
$this->original_stylesheet = get_stylesheet();
41+
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
42+
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
3343

3444
// /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
3545
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
@@ -53,6 +63,11 @@ public function tear_down() {
5363

5464
wp_clean_themes_cache();
5565
unset( $GLOBALS['wp_themes'] );
66+
67+
if ( get_stylesheet() !== $this->original_stylesheet ) {
68+
switch_theme( $this->original_stylesheet );
69+
}
70+
5671
unregister_block_type( $this->test_block_name );
5772
$this->test_block_name = null;
5873
parent::tear_down();

0 commit comments

Comments
 (0)