Changeset 51149 for trunk/tests/phpunit/tests/theme/wpThemeJson.php
- Timestamp:
- 06/15/2021 08:50:26 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r51137 r51149 65 65 } 66 66 67 function test_get_settings_presets_are_keyed_by_origin() { 68 $core_origin = new WP_Theme_JSON( 69 array( 70 'version' => WP_Theme_JSON::LATEST_SCHEMA, 71 'settings' => array( 72 'color' => array( 73 'palette' => array( 74 array( 75 'slug' => 'white', 76 'color' => 'white', 77 ), 78 ), 79 ), 80 'invalid/key' => 'value', 81 'blocks' => array( 82 'core/group' => array( 83 'color' => array( 84 'palette' => array( 85 array( 86 'slug' => 'white', 87 'color' => 'white', 88 ), 89 ), 90 ), 91 ), 92 ), 93 ), 94 ), 95 'core' 96 ); 97 $no_origin = new WP_Theme_JSON( 98 array( 99 'version' => WP_Theme_JSON::LATEST_SCHEMA, 100 'settings' => array( 101 'color' => array( 102 'palette' => array( 103 array( 104 'slug' => 'black', 105 'color' => 'black', 106 ), 107 ), 108 ), 109 'invalid/key' => 'value', 110 'blocks' => array( 111 'core/group' => array( 112 'color' => array( 113 'palette' => array( 114 array( 115 'slug' => 'black', 116 'color' => 'black', 117 ), 118 ), 119 ), 120 ), 121 ), 122 ), 123 ) 124 ); 125 126 $actual_core = $core_origin->get_raw_data(); 127 $actual_no_origin = $no_origin->get_raw_data(); 128 129 $expected_core = array( 130 'version' => WP_Theme_JSON::LATEST_SCHEMA, 131 'settings' => array( 132 'color' => array( 133 'palette' => array( 134 'core' => array( 135 array( 136 'slug' => 'white', 137 'color' => 'white', 138 ), 139 ), 140 ), 141 ), 142 'blocks' => array( 143 'core/group' => array( 144 'color' => array( 145 'palette' => array( 146 'core' => array( 147 array( 148 'slug' => 'white', 149 'color' => 'white', 150 ), 151 ), 152 ), 153 ), 154 ), 155 ), 156 ), 157 ); 158 $expected_no_origin = array( 159 'version' => WP_Theme_JSON::LATEST_SCHEMA, 160 'settings' => array( 161 'color' => array( 162 'palette' => array( 163 'theme' => array( 164 array( 165 'slug' => 'black', 166 'color' => 'black', 167 ), 168 ), 169 ), 170 ), 171 'blocks' => array( 172 'core/group' => array( 173 'color' => array( 174 'palette' => array( 175 'theme' => array( 176 array( 177 'slug' => 'black', 178 'color' => 'black', 179 ), 180 ), 181 ), 182 ), 183 ), 184 ), 185 ), 186 ); 187 188 $this->assertEqualSetsWithIndex( $expected_core, $actual_core ); 189 $this->assertEqualSetsWithIndex( $expected_no_origin, $actual_no_origin ); 190 } 191 67 192 function test_get_stylesheet() { 68 193 $theme_json = new WP_Theme_JSON( … … 70 195 'version' => WP_Theme_JSON::LATEST_SCHEMA, 71 196 'settings' => array( 72 'color' => array(197 'color' => array( 73 198 'text' => 'value', 74 199 'palette' => array( … … 79 204 ), 80 205 ), 81 'misc' => 'value', 82 'blocks' => array( 206 'typography' => array( 207 'fontFamilies' => array( 208 array( 209 'slug' => 'small', 210 'fontFamily' => '14px', 211 ), 212 array( 213 'slug' => 'big', 214 'fontFamily' => '41px', 215 ), 216 ), 217 ), 218 'misc' => 'value', 219 'blocks' => array( 83 220 'core/group' => array( 84 221 'custom' => array( … … 266 403 ), 267 404 ), 268 ) 405 ), 406 'core' 269 407 ); 270 408 … … 279 417 */ 280 418 public function test_merge_incoming_data() { 281 $initial = array( 282 'version' => WP_Theme_JSON::LATEST_SCHEMA, 283 'settings' => array( 284 'color' => array( 285 'custom' => false, 286 'palette' => array( 287 array( 288 'slug' => 'red', 289 'color' => 'red', 290 ), 291 array( 292 'slug' => 'green', 293 'color' => 'green', 294 ), 295 ), 296 ), 297 'blocks' => array( 298 'core/paragraph' => array( 299 'color' => array( 300 'custom' => false, 301 ), 302 ), 303 ), 304 ), 305 'styles' => array( 306 'typography' => array( 307 'fontSize' => '12', 308 ), 309 ), 419 $theme_json = new WP_Theme_JSON( 420 array( 421 'version' => WP_Theme_JSON::LATEST_SCHEMA, 422 'settings' => array( 423 'color' => array( 424 'custom' => false, 425 'palette' => array( 426 array( 427 'slug' => 'red', 428 'color' => 'red', 429 ), 430 array( 431 'slug' => 'green', 432 'color' => 'green', 433 ), 434 ), 435 ), 436 'blocks' => array( 437 'core/paragraph' => array( 438 'color' => array( 439 'custom' => false, 440 ), 441 ), 442 ), 443 ), 444 'styles' => array( 445 'typography' => array( 446 'fontSize' => '12', 447 ), 448 ), 449 ) 310 450 ); 311 451 … … 437 577 'customGradient' => true, 438 578 'palette' => array( 439 array( 440 'slug' => 'red', 441 'color' => 'red', 442 ), 443 array( 444 'slug' => 'green', 445 'color' => 'green', 446 ), 447 array( 448 'slug' => 'blue', 449 'color' => 'blue', 579 'theme' => array( 580 array( 581 'slug' => 'blue', 582 'color' => 'blue', 583 ), 450 584 ), 451 585 ), 452 586 'gradients' => array( 453 array( 454 'slug' => 'gradient', 455 'gradient' => 'gradient', 587 'theme' => array( 588 array( 589 'slug' => 'gradient', 590 'gradient' => 'gradient', 591 ), 456 592 ), 457 593 ), … … 459 595 'typography' => array( 460 596 'fontSizes' => array( 461 array( 462 'slug' => 'fontSize', 463 'size' => 'fontSize', 597 'theme' => array( 598 array( 599 'slug' => 'fontSize', 600 'size' => 'fontSize', 601 ), 464 602 ), 465 603 ), … … 503 641 ); 504 642 505 $theme_json = new WP_Theme_JSON( $initial );506 643 $theme_json->merge( new WP_Theme_JSON( $add_new_block ) ); 507 644 $theme_json->merge( new WP_Theme_JSON( $add_key_in_settings ) );
Note: See TracChangeset
for help on using the changeset viewer.