Repository navigation
Tests: Add unit tests for get_category() - #14363
shail-mehta wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The tests match existing behavior and use isolated fixtures; no blocking issues were identified, though tests were not executed.
No open issues 🎉
What changed in this PR
Adds dedicated PHPUnit coverage for get_category() toward Trac #65819, without changing production code.
Changes:
- Tests object and array outputs, including backwards-compatible properties.
- Covers filter context, empty inputs, missing categories, and other-taxonomy IDs.
| File | Description |
|---|---|
| tests/phpunit/tests/category/getCategory.php | Adds fixtures and dedicated get_category() tests with @covers. |
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 (12 tests) and multisite (12 tests); PHPCS and current CI pass.
Optional follow-up: add a literal field check to the numeric-array case so its expected values do not rely entirely on WP_Term::to_array().
AI review · gpt-6
|
PR #14363 landed in https://core.trac.wordpress.org/changeset/64456 |
Covers category lookup by ID and object, array output, edit-con filtering, and invalid or wrong-taxonomy inputs. Developed in: #14363 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64456 602fd350-edb4-49c9-b593-d223f7449a82
Covers category lookup by ID and object, array output, edit-con filtering, and invalid or wrong-taxonomy inputs. Developed in: WordPress/wordpress-develop#14363 Props shailu25. See #65819. Built from https://develop.svn.wordpress.org/trunk@64456 git-svn-id: http://core.svn.wordpress.org/trunk@63606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
What
Trac ticket: #65819
Adds unit tests for
get_category()intests/phpunit/tests/category/getCategory.php.Why
get_category()currently has no unit test coverage.How
Adds
Tests_Category_GetCategoryto test object/array return formats, backwards-compatible properties, filter context sanitization, and error/null handling for invalid or non-category terms.Testing Instructions
npm run test:php -- --filter Tests_Category_GetCategoryUse of AI Tools