Skip to content

Commit

Permalink
Backport 61842 PHPUnit wpThemeJson.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlende committed May 23, 2024
1 parent b31af5d commit be649bd
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions tests/phpunit/tests/theme/wpThemeJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -4434,10 +4434,10 @@ public function test_set_spacing_sizes( $spacing_scale, $expected_output ) {
'spacingScale' => $spacing_scale,
),
),
)
),
'default'
);

$theme_json->set_spacing_sizes();
$this->assertSame( $expected_output, _wp_array_get( $theme_json->get_raw_data(), array( 'settings', 'spacing', 'spacingSizes', 'default' ) ) );
}

Expand Down Expand Up @@ -4720,17 +4720,6 @@ public function test_set_spacing_sizes_when_invalid( $spacing_scale, $expected_o
$this->expectException( Exception::class );
$this->expectExceptionMessage( 'Some of the theme.json settings.spacing.spacingScale values are invalid' );

$theme_json = new WP_Theme_JSON(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'spacing' => array(
'spacingScale' => $spacing_scale,
),
),
)
);

// Ensure PHPUnit 10 compatibility.
set_error_handler(
static function ( $errno, $errstr ) {
Expand All @@ -4740,7 +4729,17 @@ static function ( $errno, $errstr ) {
E_ALL
);

$theme_json->set_spacing_sizes();
$theme_json = new WP_Theme_JSON(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'spacing' => array(
'spacingScale' => $spacing_scale,
),
),
),
'default'
);

restore_error_handler();

Expand Down

0 comments on commit be649bd

Please sign in to comment.