Skip to content

Commit bb3b81b

Browse files
committed
Tests: Remove @runInSeparateProcess from tests in Tests_Sitemaps_Sitemaps
`@runInSeparateProcess` reruns `tests/phpunit/includes/bootstrap.php`, which deletes all posts, which changes the conditions of the test. In particular, `test_disable_sitemap_should_return_404()` is supposed to test what happens if sitemaps are disabled, not what happens when there are no posts in the sitemap.
1 parent 971e12a commit bb3b81b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎tests/phpunit/tests/sitemaps/sitemaps.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,17 @@ public function test_sitemaps_enabled() {
464464

465465
/**
466466
* @ticket 50643
467-
* @runInSeparateProcess
468-
* @preserveGlobalState disabled
469467
*/
470468
public function test_disable_sitemap_should_return_404() {
471469
add_filter( 'wp_sitemaps_enabled', '__return_false' );
472470

471+
// Instantiate the server before navigating: registering the sitemap
472+
// rewrite tags is what adds `sitemap` to `$wp->public_query_vars`.
473+
$sitemaps = wp_sitemaps_get_server();
474+
473475
$this->go_to( home_url( '/?sitemap=index' ) );
474476

475-
wp_sitemaps_get_server()->render_sitemaps();
477+
$sitemaps->render_sitemaps();
476478

477479
remove_filter( 'wp_sitemaps_enabled', '__return_false' );
478480

@@ -481,8 +483,6 @@ public function test_disable_sitemap_should_return_404() {
481483

482484
/**
483485
* @ticket 50643
484-
* @runInSeparateProcess
485-
* @preserveGlobalState disabled
486486
*/
487487
public function test_empty_url_list_should_return_404() {
488488
wp_register_sitemap_provider( 'foo', new WP_Sitemaps_Empty_Test_Provider( 'foo' ) );

0 commit comments

Comments
 (0)