Tests: Add unit test coverage for Block Bindings core/term-data source - #13981
Closed
huzaifaalmesbah wants to merge 1 commit into
Closed
huzaifaalmesbah wants to merge 1 commit into
huzaifaalmesbah wants to merge 1 commit into
Conversation
|
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
self-requested a review
October 4, 2026 19:32
Member
|
Optional follow-up for this PR: add markup/entity fixtures with literal expected output to protect name escaping and description sanitization. The current plain-text fixtures do not detect removal of those transformations. |
wporg-sync
pushed a commit
that referenced
this pull request
Oct 4, 2026
Add tests for `core/term-data` field values, missing or invalid inputs, navigation block attributes, and access to non-publicly queryable taxonomies. Verify source registration metadata, repeated registration, and value retrieval through the registered source. Developed in: #13981 Props huzaifaalmesbah. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64086 602fd350-edb4-49c9-b593-d223f7449a82
lancewillett
approved these changes
Oct 4, 2026
Member
|
PR #13981 landed in https://core.trac.wordpress.org/changeset/64086 |
wporg-sync
pushed a commit
to WordPress/WordPress
that referenced
this pull request
Oct 4, 2026
Add tests for `core/term-data` field values, missing or invalid inputs, navigation block attributes, and access to non-publicly queryable taxonomies. Verify source registration metadata, repeated registration, and value retrieval through the registered source. Developed in: WordPress/wordpress-develop#13981 Props huzaifaalmesbah. See #65819. Built from https://develop.svn.wordpress.org/trunk@64086 git-svn-id: http://core.svn.wordpress.org/trunk@63245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds comprehensive unit test coverage for the Block Bindings
core/term-datasource (src/wp-includes/block-bindings/term-data.php) intests/phpunit/tests/block-bindings/termDataSource.php.The
core/term-datasource was introduced in r60946 (#64107) and updated in r60958 (#64112), but lacked a dedicated PHPUnit test file verifying its getter callback, boundary conditions, navigation block attribute fallbacks, permission checks, and source registration.Trac ticket: https://core.trac.wordpress.org/ticket/65819
Changes & New Tests Added
Input validation & boundary checks:
test_get_value_returns_null_when_field_empty: Verifiesnullis returned when thefieldargument is omitted or empty (tested via data provider).test_get_value_returns_null_when_context_empty: Verifiesnullis returned when required block context (termIdortaxonomy) is missing or invalid.test_get_value_returns_null_when_term_not_found: Confirmsnullreturn for non-existent terms.test_get_value_returns_null_when_taxonomy_invalid: Confirmsnullreturn for invalid taxonomy names.test_get_value_returns_null_for_unsupported_field: Confirmsnullreturn for unrecognized field keys.Supported field value computation:
test_get_value_returns_supported_fields: Data provider testingname,slug,description, andcount.test_get_value_link_field: Tests term permalink generation viaget_term_link().test_get_value_id_and_parent_fields: Tests string casting and escaping for term ID and parent ID.Navigation block compatibility:
test_get_value_navigation_link_attributes: Verifies readingidandtypeattributes forcore/navigation-link.test_get_value_navigation_submenu_attributes: Verifies reading attributes forcore/navigation-submenu.test_get_value_navigation_link_maps_tag_type_to_post_tag: Verifies UI shorthandtagmapping topost_tagtaxonomy slug.test_get_value_navigation_link_missing_attributes: Verifiesnullreturn when navigation attributes are missing.Permissions & visibility:
test_get_value_non_publicly_queryable_taxonomy_unauthenticated: Verifies unauthenticated users cannot read private taxonomies.test_get_value_non_publicly_queryable_taxonomy_with_read_capability: Verifies users withreadcapability can access private taxonomies.Source registration & integration:
test_register_block_bindings_term_data_source: Verifies source registration metadata (label,uses_context).test_register_block_bindings_term_data_source_idempotent: Verifies registration idempotence.test_source_get_value_integration: Verifies end-to-end lookup throughWP_Block_Bindings_Source::get_value().Testing Instructions
Run the unit test suite:
Run multisite:
Run the entire block-bindings test group:
Use of AI Tools
AI assistance: Yes
Model(s): Gemini 3.8 Flash
Used for: Analyzing execution branches and edge cases in
src/wp-includes/block-bindings/term-data.php, structuring test cases with data providers, and drafting this PR summary. All generated tests (28 tests, 34 assertions across single-site and multisite) and coding standards compliance were reviewed, executed, and verified locally in a Docker environment.