Tests: Clean up the wp_delete_post() unit tests - #13036
Conversation
Removes the unused `$user_ids` property and its `wpSetUpBeforeClass()` method. Both were copied over from the `wp_insert_post()` tests and created three users for every test in the class without a single test referencing them. Renames `test_wp_delete_post_returns_false_for_invalid_post()` to `test_wp_delete_post_returns_null_for_already_deleted_post()`. The test asserts `assertNull()`, which is the correct expectation: for an ID with no matching row, `wp_delete_post()` returns the `null` coming out of `$wpdb->get_row()`, whereas `false` is only returned by the `$post_id <= 0` guard. The previous name described the opposite of what is being covered. Reuses the existing `$actions` array in the assertion loop of `test_wp_delete_post_actions()` instead of repeating the same six action names inline, so the registration loop and the assertion loop cannot drift apart.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Description
Four independent clean-ups in the test file. Follow-up to [60906].
$user_idsfixture. The property and itswpSetUpBeforeClass()method were copied over from thewp_insert_post()tests. Nothing in this class referencesself::$user_ids, so the only effect was creating three users for every test in the class.test_wp_delete_post_returns_false_for_invalid_post()totest_wp_delete_post_returns_null_for_already_deleted_post(). The test assertsassertNull(), and that is the correct expectation: for an ID with no matching row,wp_delete_post()returns thenullcoming out of$wpdb->get_row(), whereasfalseis only returned by the$post_id <= 0guard. The old name described the opposite of what the test covers.$actionsarray in the assertion loop oftest_wp_delete_post_actions(). The same six action names were spelled out a second time inline, so the registration loop and the assertion loop could drift apart.@ticket @63975annotation. The stray@made the tag invalid, so the test was not associated with the ticket.No assertion was added, removed or changed, and no test behaviour changes.
Trac ticket: https://core.trac.wordpress.org/ticket/65819
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.