Skip to content

Commit d0262ec

Browse files
committed
Editor: Ensure PHPUnit10 compatibility for ThemeJson unit test.
Expecting E_STRICT, E_NOTICE, and E_USER_NOTICE errors is deprecated in PHPUnit 10. This updates the test to rely on an exception instead. Props antonvlasenko. Fixes #60305. git-svn-id: https://develop.svn.wordpress.org/trunk@57332 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2e3b292 commit d0262ec

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

tests/phpunit/tests/theme/wpThemeJson.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4281,8 +4281,8 @@ public function data_generate_spacing_scale_fixtures() {
42814281
* @param array $expected_output Expected output from data provider.
42824282
*/
42834283
public function test_set_spacing_sizes_should_detect_invalid_spacing_scale( $spacing_scale, $expected_output ) {
4284-
$this->expectNotice();
4285-
$this->expectNoticeMessage( 'Some of the theme.json settings.spacing.spacingScale values are invalid' );
4284+
$this->expectException( Exception::class );
4285+
$this->expectExceptionMessage( 'Some of the theme.json settings.spacing.spacingScale values are invalid' );
42864286

42874287
$theme_json = new WP_Theme_JSON(
42884288
array(
@@ -4295,6 +4295,15 @@ public function test_set_spacing_sizes_should_detect_invalid_spacing_scale( $spa
42954295
)
42964296
);
42974297

4298+
// Ensure PHPUnit 10 compatibility.
4299+
set_error_handler(
4300+
static function ( $errno, $errstr ) {
4301+
restore_error_handler();
4302+
throw new Exception( $errstr, $errno );
4303+
},
4304+
E_ALL
4305+
);
4306+
42984307
$theme_json->set_spacing_sizes();
42994308
$this->assertSame( $expected_output, _wp_array_get( $theme_json->get_raw_data(), array( 'settings', 'spacing', 'spacingSizes', 'default' ) ) );
43004309
}

0 commit comments

Comments
 (0)