Skip to content

Commit 59cfe4e

Browse files
committed
Reset REST server intance to avoid breaking tests.
1 parent 260773d commit 59cfe4e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/phpunit/tests/rest-api/rest-collaboration-server.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public static function wpTearDownAfterClass() {
2727
self::delete_user( self::$subscriber_id );
2828
remove_filter( 'pre_option_wp_collaboration_enabled', '__return_true' );
2929
wp_delete_post( self::$post_id, true );
30+
31+
// Reset the global REST server so rest_get_server() builds a fresh instance for subsequent test suites.
32+
$GLOBALS['wp_rest_server'] = null;
3033
}
3134

3235
public function set_up() {
@@ -39,6 +42,9 @@ public function set_up() {
3942
// in the test suite. TRUNCATE implicitly commits the transaction.
4043
global $wpdb;
4144
$wpdb->query( "DELETE FROM {$wpdb->collaboration}" );
45+
46+
// Reset the global REST server so rest_get_server() builds a fresh instance based on the option setting.
47+
$GLOBALS['wp_rest_server'] = null;
4248
}
4349

4450
/**

0 commit comments

Comments
 (0)