Skip to content

Commit 26f0a1a

Browse files
committed
Enhance unit tests for WP_Theme_JSON by adding descriptive messages to assertions. This improves clarity on expected outcomes for lightbox settings and appearance tools, ensuring better maintainability and understanding of test intentions.
1 parent 62f13ff commit 26f0a1a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/phpunit/tests/theme/wpThemeJson.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6644,8 +6644,8 @@ public function test_sanitize_preserves_boolean_values_when_schema_expects_boole
66446644
);
66456645

66466646
$settings = $theme_json->get_settings();
6647-
$this->assertTrue( $settings['lightbox']['enabled'] );
6648-
$this->assertFalse( $settings['lightbox']['allowEditing'] );
6647+
$this->assertTrue( $settings['lightbox']['enabled'], 'Enabled should be true' );
6648+
$this->assertFalse( $settings['lightbox']['allowEditing'], 'Allow editing should be false' );
66496649
}
66506650

66516651
/**
@@ -6668,8 +6668,8 @@ public function test_sanitize_removes_non_boolean_values_when_schema_expects_boo
66686668
);
66696669

66706670
$settings = $theme_json->get_settings();
6671-
$this->assertArrayNotHasKey( 'enabled', $settings['lightbox'] ?? array() );
6672-
$this->assertArrayNotHasKey( 'allowEditing', $settings['lightbox'] ?? array() );
6671+
$this->assertArrayNotHasKey( 'enabled', $settings['lightbox'] ?? array(), 'Enabled should be removed' );
6672+
$this->assertArrayNotHasKey( 'allowEditing', $settings['lightbox'] ?? array(), 'Allow editing should be removed' );
66736673
}
66746674

66756675
/**
@@ -6696,8 +6696,8 @@ public function test_sanitize_preserves_boolean_values_in_block_settings() {
66966696
);
66976697

66986698
$settings = $theme_json->get_settings();
6699-
$this->assertTrue( $settings['blocks']['core/image']['lightbox']['enabled'] );
6700-
$this->assertFalse( $settings['blocks']['core/image']['lightbox']['allowEditing'] );
6699+
$this->assertTrue( $settings['blocks']['core/image']['lightbox']['enabled'], 'Enabled should be true' );
6700+
$this->assertFalse( $settings['blocks']['core/image']['lightbox']['allowEditing'], 'Allow editing should be false' );
67016701
}
67026702

67036703
/**
@@ -6725,8 +6725,8 @@ public function test_sanitize_removes_non_boolean_values_in_block_settings() {
67256725

67266726
$settings = $theme_json->get_settings();
67276727
$lightbox = $settings['blocks']['core/image']['lightbox'] ?? array();
6728-
$this->assertArrayNotHasKey( 'enabled', $lightbox );
6729-
$this->assertArrayNotHasKey( 'allowEditing', $lightbox );
6728+
$this->assertArrayNotHasKey( 'enabled', $lightbox, 'Enabled should be removed' );
6729+
$this->assertArrayNotHasKey( 'allowEditing', $lightbox, 'Allow editing should be removed' );
67306730
}
67316731

67326732
/**
@@ -6748,7 +6748,7 @@ public function test_sanitize_preserves_null_schema_behavior() {
67486748
);
67496749

67506750
$settings = $theme_json->get_settings();
6751-
$this->assertSame( 'string-value', $settings['appearanceTools'] );
6752-
$this->assertSame( array( 'nested' => 'value' ), $settings['custom'] );
6751+
$this->assertSame( 'string-value', $settings['appearanceTools'], 'Appearance tools should be string value' );
6752+
$this->assertSame( array( 'nested' => 'value' ), $settings['custom'], 'Custom should be array value' );
67536753
}
67546754
}

0 commit comments

Comments
 (0)