Skip to content

Commit

Permalink
Fix phpunit failures (#51950)
Browse files Browse the repository at this point in the history
* Fix phpunit failures

* Add comment

* Update comment with actual reason this fix works
  • Loading branch information
noisysocks authored Jun 27, 2023
1 parent aaf84f3 commit 40aa280
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions phpunit/block-template-utils-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
switch_theme( 'emptytheme' );
}

public static function wpSetUpBeforeClass() {
register_post_type(
'custom_book',
array(
Expand All @@ -22,9 +19,10 @@ public static function wpSetUpBeforeClass() {
register_taxonomy( 'book_type', 'custom_book' );
}

public static function wpTearDownAfterClass() {
public function tear_down() {
unregister_post_type( 'custom_book' );
unregister_taxonomy( 'book_type' );
parent::tear_down();
}

public function test_get_template_hierarchy() {
Expand Down
6 changes: 6 additions & 0 deletions phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
define( 'LOCAL_WP_ENVIRONMENT_TYPE', 'local' );
}

// Pretend that these are Core unit tests. This is needed so that
// wp_theme_has_theme_json() does not cache its return value between each test.
if ( ! defined( 'WP_RUN_CORE_TESTS' ) ) {
define( 'WP_RUN_CORE_TESTS', true );
}

// Require composer dependencies.
require_once dirname( __DIR__ ) . '/vendor/autoload.php';

Expand Down

0 comments on commit 40aa280

Please sign in to comment.