Tests: Reset the $wp_sitemap global after each test, so that sitemaps are re-initialized when the next test runs.

This ensures consistent results in query var tests, regardless of whether they are run in isolation or as part of a larger group of tests.

Props pbiron, peterwilsoncc.
Fixes #51154.

git-svn-id: https://develop.svn.wordpress.org/trunk@48908 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-08-31 03:57:50 +00:00
parent 73375c4b32
commit d841231933
2 changed files with 7 additions and 0 deletions

View File

@ -161,6 +161,9 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
$GLOBALS[ $global ] = null;
}
// Reset $wp_sitemap global so that sitemap-related dynamic $wp->public_query_vars are added when the next test runs.
$GLOBALS['wp_sitemaps'] = null;
$this->unregister_all_meta_keys();
remove_theme_support( 'html5' );
remove_filter( 'query', array( $this, '_create_temporary_tables' ) );

View File

@ -9,6 +9,7 @@ class Tests_Query_Vars extends WP_UnitTestCase {
/**
* @ticket 35115
* @ticket 51154
*/
public function testPublicQueryVarsAreAsExpected() {
global $wp;
@ -70,6 +71,9 @@ class Tests_Query_Vars extends WP_UnitTestCase {
// Dynamically added public query vars:
'post_format',
'rest_route',
'sitemap',
'sitemap-subtype',
'sitemap-stylesheet',
),
$wp->public_query_vars,