WP_Theme_JSON_Gutenberg Unit tests: fix phpunit warnings about set_spacing_sizes#55313
Conversation
|
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/class-wp-theme-json-gutenberg.php ❔ phpunit/class-wp-theme-json-test.php |
glendaviesnz
left a comment
There was a problem hiding this comment.
LGTM - thanks for fixing this.
|
This code is in Core, so I wonder how changing trigger_error() to _doing_it_wrong() could affect backward compatibility, @matiasbenedetto. |
|
Thanks @glendaviesnz and @anton-vlasenko for the review.
I think this is not in core because this is the Gutenberg version of this class ( So I think there won't be disruptions. |
|
I've explained why replacing trigger_error() with _doing_it_wrong() could be an issue here: #55354. |
| || ( '+' !== $spacing_scale['operator'] && '*' !== $spacing_scale['operator'] ) ) { | ||
| if ( ! empty( $spacing_scale ) ) { | ||
| trigger_error( __( 'Some of the theme.json settings.spacing.spacingScale values are invalid', 'gutenberg' ), E_USER_NOTICE ); | ||
| _doing_it_wrong( __METHOD__, __( 'Some of the theme.json settings.spacing.spacingScale values are invalid', 'gutenberg' ), '6.1.0' ); |
There was a problem hiding this comment.
There was a problem hiding this comment.
But I can also see that Gutnberg trunk does not contain this change
gutenberg/lib/class-wp-theme-json-gutenberg.php
Lines 3516 to 3518 in fb71e4b
There was a problem hiding this comment.
...and phpunit changes were commit as part of WordPress/wordpress-develop#5911
|
✅ I updated the PHP Sync Tracking Issue for WP 6.5 to note this PR does not require a backport for WP 6.5. Why? Because related changes were backported in #55313 instead. cc @matiasbenedetto and @anton-vlasenko for 👍 |
What?
WP_Theme_JSON_Gutenbergunit tests: fix phpunit warnings aboutset_spacing_sizes().Why?
To avoid the warnings on the console:
How?
using core function _doing_it_wrong() to throw the notice and using
setExpectedIncorrectUsageto assert the incorrect usage notice.Testing Instructions
Run PHP unit tests with and without this change.
You should not see the warning running this PR.