Skip to content

Tests: Add unit tests for the uncovered code of the content ability - #15712

Closed
hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:66549-content-ability-tests
Closed

hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:66549-content-ability-tests

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Adds tests for code of the core/content-query ability that no test runs, according to the Codecov report.

  • An inherited post whose parents loop back to it is denied, and the check ends.
  • An inherited post is denied when its parent is of a post type that is not exposed.
  • A post with a status that is not registered is denied, even for an administrator.
  • A post whose status is not a string is denied.
  • The execute callback reads a single integer or float ID that is not in a list, and rejects ids that are not a list, a number or a string.

Testing

vendor/bin/phpunit --filter 'Tests_Abilities_API_WpRegisterCoreContentAbility::'
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Abilities_API_WpRegisterCoreContentAbility::'
vendor/bin/phpcs tests/phpunit/tests/abilities-api/wpRegisterCoreContentAbility.php

Mutation check: 4 of 5 changes to class-wp-abilities-content.php were caught.

  • The change that removes the "status is not a string" check survives. It is an equivalent change: get_post_status_object( false ) returns null, and the next check returns false for it too. The test still runs that line.
  • The two changes that remove the loop guard (the isset() check and the $checked_post_ids update) were not run, because they recurse without end. The test fails instead of hanging only if the guard works.

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.


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.

@github-actions

github-actions Bot commented Nov 6, 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 hmbashar.

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.

@hmbashar hmbashar closed this Nov 12, 2026
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.

1 participant