diff --git a/tests/WP/Dashboard/User_Interface/Readability_Scores/Get_Scores_Test.php b/tests/WP/Dashboard/User_Interface/Readability_Scores/Get_Scores_Test.php index cbcd8f3f11b..3e839f4d8aa 100644 --- a/tests/WP/Dashboard/User_Interface/Readability_Scores/Get_Scores_Test.php +++ b/tests/WP/Dashboard/User_Interface/Readability_Scores/Get_Scores_Test.php @@ -69,13 +69,14 @@ public function test_get_readability_scores( $inserted_posts, $taxonomy_filter, $request->set_param( 'term', $term_id ); } + $new_ids = []; foreach ( $inserted_posts as $key => $post ) { $meta_input = []; foreach ( $post['meta_input'] as $meta_key => $meta_value ) { $meta_input[ $meta_key ] = $meta_value; } - $this->factory()->post->create( + $new_ids[] = self::factory()->post->create( [ 'post_title' => 'Test Post ' . $key, 'post_status' => 'publish', @@ -115,7 +116,12 @@ public function test_get_readability_scores( $inserted_posts, $taxonomy_filter, $this->assertEquals( $response_data['scores'][2]['links']['view'], 'http://example.org/wp-admin/edit.php?post_status=publish&post_type=blog-post&readability_filter=bad' . $link_suffix ); $this->assertEquals( $response_data['scores'][3]['links']['view'], 'http://example.org/wp-admin/edit.php?post_status=publish&post_type=blog-post&readability_filter=na' . $link_suffix ); + // Clean up. + foreach ( $new_ids as $new_id ) { + \wp_delete_post( $new_id, true ); + } \unregister_post_type( 'blog-post' ); + \wp_delete_term( $term_id, 'category' ); } /** diff --git a/tests/WP/Dashboard/User_Interface/SEO_Scores/Get_Scores_Test.php b/tests/WP/Dashboard/User_Interface/SEO_Scores/Get_Scores_Test.php index db0fd867d86..917a021c8f8 100644 --- a/tests/WP/Dashboard/User_Interface/SEO_Scores/Get_Scores_Test.php +++ b/tests/WP/Dashboard/User_Interface/SEO_Scores/Get_Scores_Test.php @@ -69,13 +69,14 @@ public function test_get_seo_scores( $inserted_posts, $taxonomy_filter, $expecte $request->set_param( 'term', $term_id ); } + $new_ids = []; foreach ( $inserted_posts as $key => $post ) { $meta_input = []; foreach ( $post['meta_input'] as $meta_key => $meta_value ) { $meta_input[ $meta_key ] = $meta_value; } - $this->factory()->post->create( + $new_ids[] = self::factory()->post->create( [ 'post_title' => 'Test Post ' . $key, 'post_status' => 'publish', @@ -115,7 +116,12 @@ public function test_get_seo_scores( $inserted_posts, $taxonomy_filter, $expecte $this->assertEquals( $response_data['scores'][2]['links']['view'], 'http://example.org/wp-admin/edit.php?post_status=publish&post_type=blog-post&seo_filter=bad' . $link_suffix ); $this->assertEquals( $response_data['scores'][3]['links']['view'], 'http://example.org/wp-admin/edit.php?post_status=publish&post_type=blog-post&seo_filter=na' . $link_suffix ); + // Clean up. + foreach ( $new_ids as $new_id ) { + $result = \wp_delete_post( $new_id, true ); + } \unregister_post_type( 'blog-post' ); + \wp_delete_term( $term_id, 'category' ); } /** diff --git a/tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php b/tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php index 68668c8595c..9951461b712 100644 --- a/tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php +++ b/tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php @@ -102,9 +102,9 @@ public function test_get_index_links_multiple_entries_non_paged() { */ public function test_get_index_links_empty_bucket() { - $this->factory->post->create(); - $this->excluded_posts = [ $this->factory->post->create() ]; // Remove this post. - $this->factory->post->create(); + self::factory()->post->create( [ 'post_date' => '2024-01-01 00:00:01' ] ); + $this->excluded_posts = [ self::factory()->post->create( [ 'post_date' => '2024-01-01 00:00:02' ] ) ]; // Remove this post. + self::factory()->post->create( [ 'post_date' => '2024-01-01 00:00:03' ] ); \add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', [ $this, 'exclude_post' ] ); \add_filter( 'wpseo_sitemap_entries_per_page', [ $this, 'return_one' ] ); @@ -114,6 +114,7 @@ public function test_get_index_links_empty_bucket() { // Set the page to the second one, which should not contain an entry, but should exist. \set_query_var( 'sitemap_n', '2' ); + // Load the sitemap. $sitemaps = new Sitemaps_Double();