Preserve the public and private query var properties on the global WP instance when using WP_UnitTestCase::go_to(). These properties apply to the application state, not the current request.

See #34346


git-svn-id: https://develop.svn.wordpress.org/trunk@35258 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2015-10-18 05:00:40 +00:00
parent 9fbff7f63a
commit a314c6c234

View File

@ -126,7 +126,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
}
function tearDown() {
global $wpdb, $wp_query, $post;
global $wpdb, $wp_query, $wp, $post;
$wpdb->query( 'ROLLBACK' );
if ( is_multisite() ) {
while ( ms_is_switched() ) {
@ -134,6 +134,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
}
}
$wp_query = new WP_Query();
$wp = new WP();
$post = null;
remove_theme_support( 'html5' );
remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
@ -419,7 +420,14 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
$GLOBALS['wp_the_query'] = new WP_Query();
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
$public_query_vars = $GLOBALS['wp']->public_query_vars;
$private_query_vars = $GLOBALS['wp']->private_query_vars;
$GLOBALS['wp'] = new WP();
$GLOBALS['wp']->public_query_vars = $public_query_vars;
$GLOBALS['wp']->private_query_vars = $private_query_vars;
_cleanup_query_vars();
$GLOBALS['wp']->main($parts['query']);