Skip to content

Icons: Fix viewBox casing assertion in wp_get_icon test for older WP#79576

Merged
t-hamano merged 1 commit into
trunkfrom
fix/wp-get-icon-viewbox-test
Jun 26, 2026
Merged

Icons: Fix viewBox casing assertion in wp_get_icon test for older WP#79576
t-hamano merged 1 commit into
trunkfrom
fix/wp-get-icon-viewbox-test

Conversation

@t-hamano

@t-hamano t-hamano commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #78332

What?

Fixes the test_wp_get_icon_default_attributes unit test failing on the previous major WordPress version.

https://github.com/WordPress/gutenberg/actions/runs/28224303166/job/83612783910

There was 1 failure:

1) Tests_Icons_WpGetIcon::test_wp_get_icon_default_attributes
Failed asserting that '<svg aria-hidden="true" focusable="false" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">\n
	<path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" />\n
</svg>\n
' contains "viewbox="0 0 24 24"".

/var/www/html/wp-content/plugins/gutenberg/phpunit/class-wp-icon-test.php:24
phpvfscomposer:///var/www/html/wp-content/plugins/gutenberg/vendor/phpunit/phpunit/phpunit:106

Why?

The test asserts a lowercase viewbox attribute. This only holds on WP 7.0+, where wp_kses() parses attributes via the HTML API and lowercases attribute names (viewBoxviewbox). The previous major WP version preserves the original viewBox casing, so the assertion failed there.

How?

Asserts the viewBox attribute case-insensitively so the test passes on both the latest and previous WordPress versions.

Testing Instructions

This version-dependent failure can't be reproduced in this PR's CI against trunk. Once merged, the unit test job against the previous major WordPress version should pass, confirming the fix.

Use of AI Tools

Authored with assistance from Claude Code. All changes were reviewed by the author.

The test_wp_get_icon_default_attributes test asserts a lowercase
`viewbox` attribute, which only holds on WP 7.0+ where wp_kses() parses
attributes via the HTML API and lowercases names. Older WP versions
preserve the original `viewBox` casing, so the test failed there.

Assert case-insensitively to support both.

Co-Authored-By: Claude <noreply@anthropic.com>
@t-hamano t-hamano self-assigned this Jun 26, 2026
@t-hamano t-hamano added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core labels Jun 26, 2026
@t-hamano t-hamano marked this pull request as ready for review June 26, 2026 08:10
@github-actions

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano merged commit d94b944 into trunk Jun 26, 2026
52 of 54 checks passed
@t-hamano t-hamano deleted the fix/wp-get-icon-viewbox-test branch June 26, 2026 08:42
@github-actions github-actions Bot added this to the Gutenberg 23.6 milestone Jun 26, 2026
SainathPoojary pushed a commit to SainathPoojary/gutenberg that referenced this pull request Jun 29, 2026
…ordPress#79576)

The test_wp_get_icon_default_attributes test asserts a lowercase
`viewbox` attribute, which only holds on WP 7.0+ where wp_kses() parses
attributes via the HTML API and lowercases names. Older WP versions
preserve the original `viewBox` casing, so the test failed there.

Assert case-insensitively to support both.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant