Changeset 52364 for trunk/tests/phpunit/tests/theme/wpThemeJson.php
- Timestamp:
- 12/14/2021 01:55:28 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r52329 r52364 201 201 } 202 202 203 function test_get_settings_ using_opt_in_key() {203 function test_get_settings_appearance_true_opts_in() { 204 204 $theme_json = new WP_Theme_JSON( 205 205 array( … … 207 207 'settings' => array( 208 208 'appearanceTools' => true, 209 'spacing' => array( 210 'blockGap' => false, // This should override appearanceTools. 211 ), 209 212 'blocks' => array( 210 213 'core/paragraph' => array( … … 217 220 'typography' => array( 218 221 'lineHeight' => false, // This should override appearanceTools. 222 ), 223 'spacing' => array( 224 'blockGap' => null, 219 225 ), 220 226 ), … … 236 242 ), 237 243 'spacing' => array( 238 'blockGap' => true,244 'blockGap' => false, 239 245 'margin' => true, 240 246 'padding' => true, … … 260 266 ), 261 267 'spacing' => array( 262 'blockGap' => true,268 'blockGap' => false, 263 269 'margin' => true, 264 270 'padding' => true, 265 271 ), 272 'typography' => array( 273 'lineHeight' => false, 274 ), 275 ), 276 ), 277 ); 278 279 $this->assertEqualSetsWithIndex( $expected, $actual ); 280 } 281 282 function test_get_settings_appearance_false_does_not_opt_in() { 283 $theme_json = new WP_Theme_JSON( 284 array( 285 'version' => WP_Theme_JSON::LATEST_SCHEMA, 286 'settings' => array( 287 'appearanceTools' => false, 288 'border' => array( 289 'width' => true, 290 ), 291 'blocks' => array( 292 'core/paragraph' => array( 293 'typography' => array( 294 'lineHeight' => false, 295 ), 296 ), 297 'core/group' => array( 298 'typography' => array( 299 'lineHeight' => false, 300 ), 301 ), 302 ), 303 ), 304 ) 305 ); 306 307 $actual = $theme_json->get_settings(); 308 $expected = array( 309 'appearanceTools' => false, 310 'border' => array( 311 'width' => true, 312 ), 313 'blocks' => array( 314 'core/paragraph' => array( 315 'typography' => array( 316 'lineHeight' => false, 317 ), 318 ), 319 'core/group' => array( 266 320 'typography' => array( 267 321 'lineHeight' => false, … … 1134 1188 } 1135 1189 1136 public function test_merge_incoming_data_ removes_theme_presets_with_slugs_as_default_presets() {1190 public function test_merge_incoming_data_color_presets_with_same_slugs_as_default_are_removed() { 1137 1191 $defaults = new WP_Theme_JSON( 1192 array( 1193 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1194 'settings' => array( 1195 'color' => array( 1196 'defaultPalette' => true, 1197 'palette' => array( 1198 array( 1199 'slug' => 'red', 1200 'color' => 'red', 1201 'name' => 'Red', 1202 ), 1203 array( 1204 'slug' => 'green', 1205 'color' => 'green', 1206 'name' => 'Green', 1207 ), 1208 ), 1209 ), 1210 'blocks' => array( 1211 'core/paragraph' => array( 1212 'color' => array( 1213 'palette' => array( 1214 array( 1215 'slug' => 'blue', 1216 'color' => 'blue', 1217 'name' => 'Blue', 1218 ), 1219 ), 1220 ), 1221 ), 1222 ), 1223 ), 1224 ), 1225 'default' 1226 ); 1227 $theme = new WP_Theme_JSON( 1138 1228 array( 1139 1229 'version' => WP_Theme_JSON::LATEST_SCHEMA, … … 1142 1232 'palette' => array( 1143 1233 array( 1144 'slug' => ' red',1145 'color' => ' red',1146 'name' => ' Red',1234 'slug' => 'pink', 1235 'color' => 'pink', 1236 'name' => 'Pink', 1147 1237 ), 1148 1238 array( 1149 1239 'slug' => 'green', 1150 1240 'color' => 'green', 1151 'name' => 'Green ',1241 'name' => 'Greenish', 1152 1242 ), 1153 1243 ), … … 1160 1250 'slug' => 'blue', 1161 1251 '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 1252 'name' => 'Bluish', 1198 1253 ), … … 1219 1274 'settings' => array( 1220 1275 'color' => array( 1221 'palette' => array(1276 'palette' => array( 1222 1277 'default' => array( 1223 1278 array( … … 1240 1295 ), 1241 1296 ), 1297 'defaultPalette' => true, 1242 1298 ), 1243 1299 'blocks' => array( … … 1257 1313 'color' => 'yellow', 1258 1314 'name' => 'Yellow', 1315 ), 1316 ), 1317 ), 1318 ), 1319 ), 1320 ), 1321 ), 1322 ); 1323 1324 $defaults->merge( $theme ); 1325 $actual = $defaults->get_raw_data(); 1326 1327 $this->assertEqualSetsWithIndex( $expected, $actual ); 1328 } 1329 1330 public function test_merge_incoming_data_color_presets_with_same_slugs_as_default_are_not_removed_if_defaults_are_disabled() { 1331 $defaults = new WP_Theme_JSON( 1332 array( 1333 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1334 'settings' => array( 1335 'color' => array( 1336 'defaultPalette' => true, // Emulate the defaults from core theme.json. 1337 'palette' => array( 1338 array( 1339 'slug' => 'red', 1340 'color' => 'red', 1341 'name' => 'Red', 1342 ), 1343 array( 1344 'slug' => 'green', 1345 'color' => 'green', 1346 'name' => 'Green', 1347 ), 1348 ), 1349 ), 1350 'blocks' => array( 1351 'core/paragraph' => array( 1352 'color' => array( 1353 'palette' => array( 1354 array( 1355 'slug' => 'blue', 1356 'color' => 'blue', 1357 'name' => 'Blue', 1358 ), 1359 ), 1360 ), 1361 ), 1362 ), 1363 ), 1364 ), 1365 'default' 1366 ); 1367 $theme = new WP_Theme_JSON( 1368 array( 1369 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1370 'settings' => array( 1371 'color' => array( 1372 'defaultPalette' => false, 1373 'palette' => array( 1374 array( 1375 'slug' => 'pink', 1376 'color' => 'pink', 1377 'name' => 'Pink', 1378 ), 1379 array( 1380 'slug' => 'green', 1381 'color' => 'green', 1382 'name' => 'Greenish', 1383 ), 1384 ), 1385 ), 1386 'blocks' => array( 1387 'core/paragraph' => array( 1388 'color' => array( 1389 'palette' => array( 1390 array( 1391 'slug' => 'blue', 1392 'color' => 'blue', 1393 'name' => 'Bluish', 1394 ), 1395 array( 1396 'slug' => 'yellow', 1397 'color' => 'yellow', 1398 'name' => 'Yellow', 1399 ), 1400 array( 1401 'slug' => 'green', 1402 'color' => 'green', 1403 'name' => 'Block Green', 1404 ), 1405 ), 1406 ), 1407 ), 1408 ), 1409 ), 1410 ) 1411 ); 1412 1413 $expected = array( 1414 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1415 'settings' => array( 1416 'color' => array( 1417 'defaultPalette' => false, 1418 'palette' => array( 1419 'default' => array( 1420 array( 1421 'slug' => 'red', 1422 'color' => 'red', 1423 'name' => 'Red', 1424 ), 1425 array( 1426 'slug' => 'green', 1427 'color' => 'green', 1428 'name' => 'Green', 1429 ), 1430 ), 1431 'theme' => array( 1432 array( 1433 'slug' => 'pink', 1434 'color' => 'pink', 1435 'name' => 'Pink', 1436 ), 1437 array( 1438 'slug' => 'green', 1439 'color' => 'green', 1440 'name' => 'Greenish', 1441 ), 1442 ), 1443 ), 1444 ), 1445 'blocks' => array( 1446 'core/paragraph' => array( 1447 'color' => array( 1448 'palette' => array( 1449 'default' => array( 1450 array( 1451 'slug' => 'blue', 1452 'color' => 'blue', 1453 'name' => 'Blue', 1454 ), 1455 ), 1456 'theme' => array( 1457 array( 1458 'slug' => 'blue', 1459 'color' => 'blue', 1460 'name' => 'Bluish', 1461 ), 1462 array( 1463 'slug' => 'yellow', 1464 'color' => 'yellow', 1465 'name' => 'Yellow', 1466 ), 1467 array( 1468 'slug' => 'green', 1469 'color' => 'green', 1470 'name' => 'Block Green', 1259 1471 ), 1260 1472 ),
Note: See TracChangeset
for help on using the changeset viewer.