diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index b2b3fa997b8cd..8c2857fa89d0c 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -3389,7 +3389,7 @@ public function set_spacing_sizes() { || ! is_numeric( $spacing_scale['mediumStep'] ) || ( '+' !== $spacing_scale['operator'] && '*' !== $spacing_scale['operator'] ) ) { if ( ! empty( $spacing_scale ) ) { - _doing_it_wrong( __METHOD__, __( 'Some of the theme.json settings.spacing.spacingScale values are invalid', 'gutenberg' ), '6.1.0' ); + trigger_error( __( 'Some of the theme.json settings.spacing.spacingScale values are invalid', 'gutenberg' ), E_USER_NOTICE ); } return null; } diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 35747a290ca74..6ccbe2fb1d03b 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -1282,7 +1282,8 @@ public function data_generate_spacing_scale_fixtures() { * @dataProvider data_set_spacing_sizes_when_invalid */ public function test_set_spacing_sizes_when_invalid( $spacing_scale, $expected_output ) { - $this->setExpectedIncorrectUsage( 'WP_Theme_JSON_Gutenberg::set_spacing_sizes' ); + $this->expectException( Exception::class ); + $this->expectExceptionMessage( 'Some of the theme.json settings.spacing.spacingScale values are invalid' ); $theme_json = new WP_Theme_JSON_Gutenberg( array( @@ -1295,6 +1296,15 @@ public function test_set_spacing_sizes_when_invalid( $spacing_scale, $expected_o ) ); + // Ensure PHPUnit 10 compatibility. + set_error_handler( + static function ( $errno, $errstr ) { + restore_error_handler(); + throw new Exception( $errstr, $errno ); + }, + E_ALL + ); + $theme_json->set_spacing_sizes(); $this->assertSame( $expected_output, _wp_array_get( $theme_json->get_raw_data(), array( 'settings', 'spacing', 'spacingSizes', 'default' ) ) ); }