Repository navigation
Tests: Add unit tests for has_category() - #14369
shail-mehta wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused tests match the API behavior, and no blocking issues were identified.
No open issues 🎉
What changed in this PR
Adds unit coverage for has_category() in WordPress’s category test suite, addressing Trac #65819.
Changes:
- Tests category matching by ID, name, slug, and arrays.
- Covers empty-category checks and global-post fallback.
- Verifies false results for non-matching categories and invalid posts.
| File | Description |
|---|---|
| tests/phpunit/tests/category/hasCategory.php | Adds shared fixtures and four tests for has_category(). |
Review effort: Balanced
|
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. |
lancewillett
left a comment
There was a problem hiding this comment.
Reviewed the tests against the implementation and existing coverage, including the unit-tests audit. No blocking findings. The affected classes passed locally in randomized order on single site (4 tests) and multisite (4 tests); PHPCS and current CI pass.
AI review · gpt-6
Checks matching and missing categories, the empty-category case, global-post fallback, and invalid posts. Developed in: #14369 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64463 602fd350-edb4-49c9-b593-d223f7449a82
|
PR #14369 landed in https://core.trac.wordpress.org/changeset/64463 |
Checks matching and missing categories, the empty-category case, global-post fallback, and invalid posts. Developed in: WordPress/wordpress-develop#14369 Props shailu25, mukesh27. See #65819. Built from https://develop.svn.wordpress.org/trunk@64463 git-svn-id: http://core.svn.wordpress.org/trunk@63613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
What
Trac ticket: #65819
Adds unit tests for
has_category()intests/phpunit/tests/category/hasCategory.php.Why
has_category()currently has no unit test coverage.How
Adds
Tests_Category_HasCategoryto test checking post categories by ID, name, slug, or array of values, checking whether a post has any category when$categoryis empty, defaulting to the global$post, and returningfalsefor non-matching categories or invalid posts.Testing Instructions
npm run test:php -- --filter Tests_Category_HasCategoryUse of AI Tools