Skip to content

Tests: Clean up custom post type in Tests_User_GetTheAuthorPosts - #15452

Open
devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:test/cleanup-cpt-get-the-author-posts
Open

devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:test/cleanup-cpt-get-the-author-posts

Conversation

@devmuhib009

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/65893

This PR ensures the custom post type wptests_pt registered during tests in Tests_User_GetTheAuthorPosts is cleanly unregistered in tear_down() using the public unregister_post_type() function, preventing fixture leakage and replacing the internal mid-test call.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props devmuhib.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@huzaifaalmesbah huzaifaalmesbah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @devmuhib009!

Properly unregisters the wptests_pt custom post type in tear_down() and removes the mid-test unregistration call in Tests_User_GetTheAuthorPosts, preventing fixture leakage across test suites. Looks good to me!

AI Review: Gemini 3.8 Flash

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change moving custom post type cleanup into the test teardown lifecycle.

No open issues 🎉

What changed in this PR

Moves custom post type cleanup into the test teardown lifecycle to prevent fixture leakage in Tests_User_GetTheAuthorPosts.

Changes:

  • Adds tear_down() to unregister wptests_pt using the public API before calling the parent teardown.
  • Removes the internal _unregister_post_type() call from the test body.
File Description
tests/​phpunit/​tests/​user/​getTheAuthorPosts.php Moves custom post type cleanup into teardown using unregister_post_type().

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants