Changeset 57496 for trunk/tests/phpunit/tests/theme/wpThemeJson.php
- Timestamp:
- 01/31/2024 10:53:48 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r57491 r57496 4979 4979 ); 4980 4980 } 4981 4982 /** 4983 * Tests that invalid properties are removed from the theme.json inside indexed arrays as settings.typography.fontFamilies. 4984 * 4985 * @ticket 60360 4986 */ 4987 public function test_sanitize_indexed_arrays() { 4988 $theme_json = new WP_Theme_JSON( 4989 array( 4990 'version' => '2', 4991 'badKey2' => 'I am Evil!', 4992 'settings' => array( 4993 'badKey3' => 'I am Evil!', 4994 'typography' => array( 4995 'badKey4' => 'I am Evil!', 4996 'fontFamilies' => array( 4997 'custom' => array( 4998 array( 4999 'badKey4' => 'I am Evil!', 5000 'name' => 'Arial', 5001 'slug' => 'arial', 5002 'fontFamily' => 'Arial, sans-serif', 5003 ), 5004 ), 5005 'theme' => array( 5006 array( 5007 'badKey5' => 'I am Evil!', 5008 'name' => 'Piazzolla', 5009 'slug' => 'piazzolla', 5010 'fontFamily' => 'Piazzolla', 5011 'fontFace' => array( 5012 array( 5013 'badKey6' => 'I am Evil!', 5014 'fontFamily' => 'Piazzolla', 5015 'fontStyle' => 'italic', 5016 'fontWeight' => '400', 5017 'src' => 'https://example.com/font.ttf', 5018 ), 5019 array( 5020 'badKey7' => 'I am Evil!', 5021 'fontFamily' => 'Piazzolla', 5022 'fontStyle' => 'italic', 5023 'fontWeight' => '400', 5024 'src' => 'https://example.com/font.ttf', 5025 ), 5026 ), 5027 ), 5028 array( 5029 'badKey8' => 'I am Evil!', 5030 'name' => 'Inter', 5031 'slug' => 'Inter', 5032 'fontFamily' => 'Inter', 5033 'fontFace' => array( 5034 array( 5035 'badKey9' => 'I am Evil!', 5036 'fontFamily' => 'Inter', 5037 'fontStyle' => 'italic', 5038 'fontWeight' => '400', 5039 'src' => 'https://example.com/font.ttf', 5040 ), 5041 array( 5042 'badKey10' => 'I am Evil!', 5043 'fontFamily' => 'Inter', 5044 'fontStyle' => 'italic', 5045 'fontWeight' => '400', 5046 'src' => 'https://example.com/font.ttf', 5047 ), 5048 ), 5049 ), 5050 ), 5051 ), 5052 ), 5053 ), 5054 ) 5055 ); 5056 5057 $expected_sanitized = array( 5058 'version' => '2', 5059 'settings' => array( 5060 'typography' => array( 5061 'fontFamilies' => array( 5062 'custom' => array( 5063 array( 5064 'name' => 'Arial', 5065 'slug' => 'arial', 5066 'fontFamily' => 'Arial, sans-serif', 5067 ), 5068 ), 5069 'theme' => array( 5070 array( 5071 'name' => 'Piazzolla', 5072 'slug' => 'piazzolla', 5073 'fontFamily' => 'Piazzolla', 5074 'fontFace' => array( 5075 array( 5076 'fontFamily' => 'Piazzolla', 5077 'fontStyle' => 'italic', 5078 'fontWeight' => '400', 5079 'src' => 'https://example.com/font.ttf', 5080 ), 5081 array( 5082 'fontFamily' => 'Piazzolla', 5083 'fontStyle' => 'italic', 5084 'fontWeight' => '400', 5085 'src' => 'https://example.com/font.ttf', 5086 ), 5087 ), 5088 ), 5089 array( 5090 'name' => 'Inter', 5091 'slug' => 'Inter', 5092 'fontFamily' => 'Inter', 5093 'fontFace' => array( 5094 array( 5095 'fontFamily' => 'Inter', 5096 'fontStyle' => 'italic', 5097 'fontWeight' => '400', 5098 'src' => 'https://example.com/font.ttf', 5099 ), 5100 array( 5101 'fontFamily' => 'Inter', 5102 'fontStyle' => 'italic', 5103 'fontWeight' => '400', 5104 'src' => 'https://example.com/font.ttf', 5105 ), 5106 ), 5107 ), 5108 ), 5109 ), 5110 ), 5111 ), 5112 ); 5113 $sanitized_theme_json = $theme_json->get_raw_data(); 5114 $this->assertSameSetsWithIndex( $expected_sanitized, $sanitized_theme_json, 'Sanitized theme.json does not match' ); 5115 } 4981 5116 }
Note: See TracChangeset
for help on using the changeset viewer.