@@ -6630,24 +6630,25 @@ public function test_merge_incoming_data_unique_slugs_always_preserved() {
66306630 * @ticket 64280
66316631 */
66326632 public function test_remove_insecure_properties_should_allow_safe_settings () {
6633- $ actual = WP_Theme_JSON ::remove_insecure_properties (
6633+ $ actual = WP_Theme_JSON_Gutenberg ::remove_insecure_properties (
66346634 array (
6635- 'version ' => WP_Theme_JSON ::LATEST_SCHEMA ,
6635+ 'version ' => WP_Theme_JSON_Gutenberg ::LATEST_SCHEMA ,
66366636 'settings ' => array (
66376637 'blocks ' => array (
66386638 'core/image ' => array (
6639- 'lightbox ' => array (
6639+ 'lightbox ' => array (
66406640 'enabled ' => false ,
66416641 'allowEditing ' => true ,
66426642 ),
6643+ 'unsupported ' => 'value ' ,
66436644 ),
66446645 ),
66456646 ),
66466647 )
66476648 );
66486649
66496650 $ expected = array (
6650- 'version ' => WP_Theme_JSON ::LATEST_SCHEMA ,
6651+ 'version ' => WP_Theme_JSON_Gutenberg ::LATEST_SCHEMA ,
66516652 'settings ' => array (
66526653 'blocks ' => array (
66536654 'core/image ' => array (
@@ -6662,35 +6663,41 @@ public function test_remove_insecure_properties_should_allow_safe_settings() {
66626663
66636664 $ this ->assertEqualSetsWithIndex ( $ expected , $ actual );
66646665 }
6665-
66666666 /**
66676667 * @covers WP_Theme_JSON::remove_insecure_properties
66686668 *
66696669 * @ticket 64280
66706670 */
6671- public function test_safe_settings_paths_should_exist_in_valid_settings () {
6672- // Verify all paths in SAFE_SETTINGS exist in VALID_SETTINGS.
6673- foreach ( WP_Theme_JSON::SAFE_SETTINGS as $ safe_setting ) {
6674- $ path = $ safe_setting ['path ' ];
6675- $ data = WP_Theme_JSON::VALID_SETTINGS ;
6676-
6677- // Check if path exists by traversing the nested structure.
6678- $ exists = true ;
6679- foreach ( $ path as $ key ) {
6680- if ( ! is_array ( $ data ) || ! array_key_exists ( $ key , $ data ) ) {
6681- $ exists = false ;
6682- break ;
6683- }
6684- $ data = $ data [ $ key ];
6685- }
6686-
6687- $ this ->assertTrue (
6688- $ exists ,
6689- sprintf (
6690- 'Path %s from SAFE_SETTINGS should exist in VALID_SETTINGS ' ,
6691- implode ( '. ' , $ path )
6692- )
6693- );
6694- }
6671+ public function test_remove_insecure_properties_should_not_allow_unsafe_settings () {
6672+ $ actual = WP_Theme_JSON_Gutenberg::remove_insecure_properties (
6673+ array (
6674+ 'version ' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA ,
6675+ 'settings ' => array (
6676+ 'blocks ' => array (
6677+ 'core/image ' => array (
6678+ 'lightbox ' => array (
6679+ 'enabled ' => 'false ' ,
6680+ 'allowEditing ' => true ,
6681+ ),
6682+ ),
6683+ ),
6684+ ),
6685+ )
6686+ );
6687+
6688+ $ expected = array (
6689+ 'version ' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA ,
6690+ 'settings ' => array (
6691+ 'blocks ' => array (
6692+ 'core/image ' => array (
6693+ 'lightbox ' => array (
6694+ 'allowEditing ' => true ,
6695+ ),
6696+ ),
6697+ ),
6698+ ),
6699+ );
6700+
6701+ $ this ->assertEqualSetsWithIndex ( $ expected , $ actual );
66956702 }
66966703}
0 commit comments