Skip to content

Commit

Permalink
Fix PHPUnit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlende committed May 30, 2024
1 parent e346f8f commit 433b54a
Showing 1 changed file with 30 additions and 42 deletions.
72 changes: 30 additions & 42 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4300,7 +4300,7 @@ public function data_set_spacing_sizes() {
),
'expected_output' => array(
array(
'name' => '1',
'name' => 'Medium',
'slug' => '50',
'size' => '4rem',
),
Expand All @@ -4316,12 +4316,12 @@ public function data_set_spacing_sizes() {
),
'expected_output' => array(
array(
'name' => '1',
'name' => 'Medium',
'slug' => '50',
'size' => '4rem',
),
array(
'name' => '2',
'name' => 'Large',
'slug' => '60',
'size' => '5.5rem',
),
Expand All @@ -4337,17 +4337,17 @@ public function data_set_spacing_sizes() {
),
'expected_output' => array(
array(
'name' => '1',
'name' => 'Small',
'slug' => '40',
'size' => '2.5rem',
),
array(
'name' => '2',
'name' => 'Medium',
'slug' => '50',
'size' => '4rem',
),
array(
'name' => '3',
'name' => 'Large',
'slug' => '60',
'size' => '5.5rem',
),
Expand All @@ -4363,22 +4363,22 @@ public function data_set_spacing_sizes() {
),
'expected_output' => array(
array(
'name' => '1',
'name' => 'Small',
'slug' => '40',
'size' => '2.5rem',
),
array(
'name' => '2',
'name' => 'Medium',
'slug' => '50',
'size' => '4rem',
),
array(
'name' => '3',
'name' => 'Large',
'slug' => '60',
'size' => '5.5rem',
),
array(
'name' => '4',
'name' => 'X-Large',
'slug' => '70',
'size' => '7rem',
),
Expand All @@ -4394,27 +4394,27 @@ public function data_set_spacing_sizes() {
),
'expected_output' => array(
array(
'name' => '1',
'name' => 'X-Small',
'slug' => '40',
'size' => '2.5rem',
),
array(
'name' => '2',
'name' => 'Small',
'slug' => '50',
'size' => '5rem',
),
array(
'name' => '3',
'name' => 'Medium',
'slug' => '60',
'size' => '7.5rem',
),
array(
'name' => '4',
'name' => 'Large',
'slug' => '70',
'size' => '10rem',
),
array(
'name' => '5',
'name' => 'X-Large',
'slug' => '80',
'size' => '12.5rem',
),
Expand All @@ -4430,27 +4430,27 @@ public function data_set_spacing_sizes() {
),
'expected_output' => array(
array(
'name' => '1',
'name' => 'X-Small',
'slug' => '30',
'size' => '0.67rem',
),
array(
'name' => '2',
'name' => 'Small',
'slug' => '40',
'size' => '1rem',
),
array(
'name' => '3',
'name' => 'Medium',
'slug' => '50',
'size' => '1.5rem',
),
array(
'name' => '4',
'name' => 'Large',
'slug' => '60',
'size' => '2.25rem',
),
array(
'name' => '5',
'name' => 'X-Large',
'slug' => '70',
'size' => '3.38rem',
),
Expand All @@ -4466,27 +4466,27 @@ public function data_set_spacing_sizes() {
),
'expected_output' => array(
array(
'name' => '1',
'name' => 'X-Small',
'slug' => '30',
'size' => '0.09rem',
),
array(
'name' => '2',
'name' => 'Small',
'slug' => '40',
'size' => '0.38rem',
),
array(
'name' => '3',
'name' => 'Medium',
'slug' => '50',
'size' => '1.5rem',
),
array(
'name' => '4',
'name' => 'Large',
'slug' => '60',
'size' => '6rem',
),
array(
'name' => '5',
'name' => 'X-Large',
'slug' => '70',
'size' => '24rem',
),
Expand Down Expand Up @@ -4555,18 +4555,6 @@ public function data_set_spacing_sizes() {
* @param array $expected_output Expected output from data provider.
*/
public function test_set_spacing_sizes_when_invalid( $spacing_scale, $expected_output ) {
$this->expectException( Exception::class );
$this->expectExceptionMessage( 'Some of the theme.json settings.spacing.spacingScale values are invalid' );

// Ensure PHPUnit 10 compatibility.
set_error_handler(
static function ( $errno, $errstr ) {
restore_error_handler();
throw new Exception( $errstr, $errno );
},
E_ALL
);

$theme_json = new WP_Theme_JSON_Gutenberg(
array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
Expand Down Expand Up @@ -4597,7 +4585,7 @@ public function data_set_spacing_sizes_when_invalid() {
'mediumStep' => 4,
'unit' => 'rem',
),
'expected_output' => null,
'expected_output' => array(),
),
'non numeric increment' => array(
'spacing_scale' => array(
Expand All @@ -4607,7 +4595,7 @@ public function data_set_spacing_sizes_when_invalid() {
'mediumStep' => 4,
'unit' => 'rem',
),
'expected_output' => null,
'expected_output' => array(),
),
'non numeric steps' => array(
'spacing_scale' => array(
Expand All @@ -4617,7 +4605,7 @@ public function data_set_spacing_sizes_when_invalid() {
'mediumStep' => 4,
'unit' => 'rem',
),
'expected_output' => null,
'expected_output' => array(),
),
'non numeric medium step' => array(
'spacing_scale' => array(
Expand All @@ -4627,7 +4615,7 @@ public function data_set_spacing_sizes_when_invalid() {
'mediumStep' => 'That which is just right',
'unit' => 'rem',
),
'expected_output' => null,
'expected_output' => array(),
),
'missing unit value' => array(
'spacing_scale' => array(
Expand All @@ -4636,7 +4624,7 @@ public function data_set_spacing_sizes_when_invalid() {
'steps' => 5,
'mediumStep' => 4,
),
'expected_output' => null,
'expected_output' => array(),
),
);
}
Expand Down

0 comments on commit 433b54a

Please sign in to comment.