From a31a167359a53a46d823cf2012df80cc49a194e9 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 17 Feb 2014 21:03:43 +0000 Subject: [PATCH] Reset `$wp_query` and `$post` during `WP_UnitTestCase::tearDown()` to avoid spillage of globals between tests. See #26321. git-svn-id: https://develop.svn.wordpress.org/trunk@27183 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 7cd7148296..5f77db201f 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -32,9 +32,11 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { } function tearDown() { - global $wpdb; + global $wpdb, $wp_query, $post; $this->expectedDeprecated(); $wpdb->query( 'ROLLBACK' ); + $wp_query = new WP_Query(); + $post = null; remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );