Opened 8 hours ago
Last modified 8 hours ago
#65751 new enhancement
wp_get_registered_image_subsizes() has no unit test coverage
| Reported by: | irozum | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Media | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
wp_get_registered_image_subsizes() in wp-includes/media.php (since 5.3.0) has no PHPUnit coverage at all — confirmed via grep -rn "wp_get_registered_image_subsizes" tests/phpunit/. It's a pure function composing get_intermediate_image_sizes() and wp_get_additional_image_sizes() into a normalized {width, height, crop} array per registered size, so it's straightforward to cover: custom sizes via add_image_size(), crop as a bool vs. a position array, sizes with no dimensions being omitted, and the intermediate_image_sizes filter. Have a PR ready with 4 tests covering these cases.
Change History (1)
This ticket was mentioned in PR #12749 on WordPress/wordpress-develop by @irozum.
8 hours ago
#1
- Keywords has-patch has-unit-tests added
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
wp_get_registered_image_subsizes()(wp-includes/media.php, since 5.3.0) had no PHPUnit coverage at all. It's a pure function that composesget_intermediate_image_sizes()andwp_get_additional_image_sizes()into a normalized{width, height, crop}array per registered image size, so it's straightforward to pin down. This adds 4 tests toTests_Media:add_image_size()shows up with the correct width/height andcropasfalse.array( 'center', 'top' )) preserves that array rather than coercing it to a bool.intermediate_image_sizesfilter can exclude a size from the result.This is a test-only change — no production behavior is added or modified. Each test was verified to actually constrain the code: I temporarily broke the corresponding logic in
wp_get_registered_image_subsizes()(inverting the crop bool cast, disabling the zero-dimension skip, disabling the filter application) and confirmed the relevant test went red, then restored the original and confirmed green again.Ran the full
Tests_Mediaclass (453 tests) after adding these — no regressions. Lint and PHPStan clean.## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Identifying the coverage gap, implementation, and mutation-testing verification of each assertion. Reviewed by @irozum.