Add unit tests for RegisteredDataHandler - #1402
Open
noruzzamans wants to merge 1 commit into
Open
noruzzamans wants to merge 1 commit into
noruzzamans wants to merge 1 commit into
Conversation
noruzzamans
marked this pull request as ready for review
September 20, 2026 09:03
noruzzamans
requested review from
peterwilsoncc
and removed request for
a team
September 20, 2026 09:03
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.
Description of the Change
Adds a comprehensive unit test suite for the
Distributor\RegisteredDataHandlerclass introduced in Distributor 2.2.0, which handles registered data processing across post content, Gutenberg blocks, shortcodes, post meta, and taxonomy terms.Prior to this PR,
Distributor\RegisteredDataHandlerhad 0% unit test coverage. This PR provides 100% test-only coverage (29 unit tests, 49 assertions) covering:search_replace_block_inner_content): Tests empty replacement handling and multi-string replacements across bothinnerHTMLandinnerContent.prepare_registered_data_term): Tests invalid/null/WP_Errorterm handling, flat taxonomy terms, and hierarchical terms with recursive parent data.process_registered_data_term): Tests empty term data, existing terms, hierarchy updates when parents differ, new term insertion viawp_insert_term(), and error handling when term creation fails.process_registered_post_meta_data): Tests missing callbacks/keys, single string meta keys, single-element array wrapped keys, and multi-key batch updates.process_blocks_data_recursive&process_registered_block_data): Tests uncallable callbacks, matching block attribute updates, media block replacement (URL,wp-image-*class, and GUID updates), nestedinnerBlocksrecursion, and fallback whenhas_block()returns false.process_registered_shortcode_data): Tests fallback whenhas_shortcode()returns false, single attribute replacements, and multiple attribute replacements.process_registered_data&pre_process_registered_data_post): Tests filter bypass (dt_process_extra_data), empty registry, meta pipeline dispatching, and external connection pre-processing guards.How to test the Change
Run the PHPUnit test suite locally:
composer testOr run the dedicated test class directly:
All 29 tests should execute and pass without errors or regressions.
Changelog Entry
Credits
Props @noruzzamans
Checklist: