Skip to content

Commit

Permalink
Troubleshoot failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leonidasmi committed Dec 9, 2024
1 parent 263a59c commit 8f5b1fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 );

Check warning on line 121 in tests/WP/Dashboard/User_Interface/SEO_Scores/Get_Scores_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Unused variable $result.

Check warning on line 121 in tests/WP/Dashboard/User_Interface/SEO_Scores/Get_Scores_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Unused variable $result.
}
\unregister_post_type( 'blog-post' );
\wp_delete_term( $term_id, 'category' );
}

/**
Expand Down
7 changes: 4 additions & 3 deletions tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );

Check failure on line 105 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space between "'post_date'" and double arrow; 3 found

Check failure on line 105 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space between "'post_date'" and double arrow; 3 found
$this->excluded_posts = [ self::factory()->post->create( [ 'post_date' => '2024-01-01 00:00:02' ] ) ]; // Remove this post.

Check failure on line 106 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space between "'post_date'" and double arrow; 3 found

Check failure on line 106 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space between "'post_date'" and double arrow; 3 found
self::factory()->post->create( [ 'post_date' => '2024-01-01 00:00:03' ] );

Check failure on line 107 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space between "'post_date'" and double arrow; 3 found

Check failure on line 107 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space between "'post_date'" and double arrow; 3 found

\add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', [ $this, 'exclude_post' ] );
\add_filter( 'wpseo_sitemap_entries_per_page', [ $this, 'return_one' ] );
Expand All @@ -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' );

Check failure on line 117 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Whitespace found at end of line

Check failure on line 117 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Functions must not contain multiple empty lines in a row; found 2 empty lines

Check failure on line 117 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Whitespace found at end of line

Check failure on line 117 in tests/WP/Sitemaps/Post_Type_Sitemap_Provider_Test.php

View workflow job for this annotation

GitHub Actions / Check code style

Functions must not contain multiple empty lines in a row; found 2 empty lines

// Load the sitemap.
$sitemaps = new Sitemaps_Double();
Expand Down

0 comments on commit 8f5b1fd

Please sign in to comment.