Changeset 52275 for trunk/tests/phpunit/tests/theme/wpThemeJson.php
- Timestamp:
- 11/30/2021 12:22:30 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r52232 r52275 201 201 } 202 202 203 function test_get_settings_using_opt_in_key() { 204 $theme_json = new WP_Theme_JSON( 205 array( 206 'version' => WP_Theme_JSON::LATEST_SCHEMA, 207 'settings' => array( 208 'appearanceTools' => true, 209 'blocks' => array( 210 'core/paragraph' => array( 211 'typography' => array( 212 'lineHeight' => false, 213 ), 214 ), 215 'core/group' => array( 216 'appearanceTools' => true, 217 'typography' => array( 218 'lineHeight' => false, // This should override appearanceTools. 219 ), 220 ), 221 ), 222 ), 223 ) 224 ); 225 226 $actual = $theme_json->get_settings(); 227 $expected = array( 228 'border' => array( 229 'width' => true, 230 'style' => true, 231 'radius' => true, 232 'color' => true, 233 ), 234 'color' => array( 235 'link' => true, 236 ), 237 'spacing' => array( 238 'blockGap' => true, 239 'margin' => true, 240 'padding' => true, 241 ), 242 'typography' => array( 243 'lineHeight' => true, 244 ), 245 'blocks' => array( 246 'core/paragraph' => array( 247 'typography' => array( 248 'lineHeight' => false, 249 ), 250 ), 251 'core/group' => array( 252 'border' => array( 253 'width' => true, 254 'style' => true, 255 'radius' => true, 256 'color' => true, 257 ), 258 'color' => array( 259 'link' => true, 260 ), 261 'spacing' => array( 262 'blockGap' => true, 263 'margin' => true, 264 'padding' => true, 265 ), 266 'typography' => array( 267 'lineHeight' => false, 268 ), 269 ), 270 ), 271 ); 272 273 $this->assertEqualSetsWithIndex( $expected, $actual ); 274 } 275 203 276 /** 204 277 * @ticket 54336 … … 1061 1134 } 1062 1135 1136 public function test_merge_incoming_data_removes_theme_presets_with_slugs_as_default_presets() { 1137 $defaults = new WP_Theme_JSON( 1138 array( 1139 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1140 'settings' => array( 1141 'color' => array( 1142 'palette' => array( 1143 array( 1144 'slug' => 'red', 1145 'color' => 'red', 1146 'name' => 'Red', 1147 ), 1148 array( 1149 'slug' => 'green', 1150 'color' => 'green', 1151 'name' => 'Green', 1152 ), 1153 ), 1154 ), 1155 'blocks' => array( 1156 'core/paragraph' => array( 1157 'color' => array( 1158 'palette' => array( 1159 array( 1160 'slug' => 'blue', 1161 'color' => 'blue', 1162 'name' => 'Blue', 1163 ), 1164 ), 1165 ), 1166 ), 1167 ), 1168 ), 1169 ), 1170 'default' 1171 ); 1172 $theme = new WP_Theme_JSON( 1173 array( 1174 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1175 'settings' => array( 1176 'color' => array( 1177 'palette' => array( 1178 array( 1179 'slug' => 'pink', 1180 'color' => 'pink', 1181 'name' => 'Pink', 1182 ), 1183 array( 1184 'slug' => 'green', 1185 'color' => 'green', 1186 'name' => 'Greenish', 1187 ), 1188 ), 1189 ), 1190 'blocks' => array( 1191 'core/paragraph' => array( 1192 'color' => array( 1193 'palette' => array( 1194 array( 1195 'slug' => 'blue', 1196 'color' => 'blue', 1197 'name' => 'Bluish', 1198 ), 1199 array( 1200 'slug' => 'yellow', 1201 'color' => 'yellow', 1202 'name' => 'Yellow', 1203 ), 1204 array( 1205 'slug' => 'green', 1206 'color' => 'green', 1207 'name' => 'Block Green', 1208 ), 1209 ), 1210 ), 1211 ), 1212 ), 1213 ), 1214 ) 1215 ); 1216 1217 $expected = array( 1218 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1219 'settings' => array( 1220 'color' => array( 1221 'palette' => array( 1222 'default' => array( 1223 array( 1224 'slug' => 'red', 1225 'color' => 'red', 1226 'name' => 'Red', 1227 ), 1228 array( 1229 'slug' => 'green', 1230 'color' => 'green', 1231 'name' => 'Green', 1232 ), 1233 ), 1234 'theme' => array( 1235 array( 1236 'slug' => 'pink', 1237 'color' => 'pink', 1238 'name' => 'Pink', 1239 ), 1240 ), 1241 ), 1242 ), 1243 'blocks' => array( 1244 'core/paragraph' => array( 1245 'color' => array( 1246 'palette' => array( 1247 'default' => array( 1248 array( 1249 'slug' => 'blue', 1250 'color' => 'blue', 1251 'name' => 'Blue', 1252 ), 1253 ), 1254 'theme' => array( 1255 array( 1256 'slug' => 'yellow', 1257 'color' => 'yellow', 1258 'name' => 'Yellow', 1259 ), 1260 ), 1261 ), 1262 ), 1263 ), 1264 ), 1265 ), 1266 ); 1267 1268 $defaults->merge( $theme ); 1269 $actual = $defaults->get_raw_data(); 1270 1271 $this->assertEqualSetsWithIndex( $expected, $actual ); 1272 } 1273 1063 1274 /** 1064 1275 * @ticket 54336 … … 1299 1510 'custom' => true, 1300 1511 'palette' => array( 1301 ' user' => array(1512 'custom' => array( 1302 1513 array( 1303 1514 'name' => 'Red', … … 1326 1537 'custom' => true, 1327 1538 'palette' => array( 1328 ' user' => array(1539 'custom' => array( 1329 1540 array( 1330 1541 'name' => 'Yellow', … … 1359 1570 'color' => array( 1360 1571 'palette' => array( 1361 ' user' => array(1572 'custom' => array( 1362 1573 array( 1363 1574 'name' => 'Red', … … 1382 1593 'color' => array( 1383 1594 'palette' => array( 1384 ' user' => array(1595 'custom' => array( 1385 1596 array( 1386 1597 'name' => 'Yellow', … … 1418 1629 'color' => array( 1419 1630 'palette' => array( 1420 ' user' => array(1631 'custom' => array( 1421 1632 array( 1422 1633 'name' => 'Red/><b>ok</ok>', … … 1444 1655 'typography' => array( 1445 1656 'fontFamilies' => array( 1446 ' user' => array(1657 'custom' => array( 1447 1658 array( 1448 1659 'name' => 'Helvetica Arial/><b>test</b>', … … 1472 1683 'color' => array( 1473 1684 'palette' => array( 1474 ' user' => array(1685 'custom' => array( 1475 1686 array( 1476 1687 'name' => 'Red/><b>ok</ok>', … … 1507 1718 'color' => array( 1508 1719 'palette' => array( 1509 ' user' => array(1720 'custom' => array( 1510 1721 array( 1511 1722 'name' => 'Pink', … … 1518 1729 'typography' => array( 1519 1730 'fontFamilies' => array( 1520 ' user' => array(1731 'custom' => array( 1521 1732 array( 1522 1733 'name' => 'Cambria', … … 1531 1742 'color' => array( 1532 1743 'palette' => array( 1533 ' user' => array(1744 'custom' => array( 1534 1745 array( 1535 1746 'name' => 'Pink',
Note: See TracChangeset
for help on using the changeset viewer.