Skip to content

Commit

Permalink
Properly set up theme directory
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Oct 28, 2022
1 parent 2b570aa commit 92db7ba
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions phpunit/wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,35 @@

class WP_Theme_Json_Test extends WP_UnitTestCase {

public function set_up() {
parent::set_up();
$this->theme_root = realpath( __DIR__ . '/data/themedir1' );

$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];

// /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );

add_filter( 'theme_root', array( $this, 'filter_set_theme_root' ) );
add_filter( 'stylesheet_root', array( $this, 'filter_set_theme_root' ) );
add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) );
$this->queries = array();
// Clear caches.
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
}

public function tear_down() {
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
parent::tear_down();
}

public function filter_set_theme_root() {
return $this->theme_root;
}

/**
* Test that it reports correctly themes that have a theme.json.
*
Expand Down

0 comments on commit 92db7ba

Please sign in to comment.