Ticket #56611: 56611.diff
| File 56611.diff, 13.0 KB (added by , 3 years ago) |
|---|
-
tests/phpunit/data/themedir1/block-theme/theme.json
diff --git tests/phpunit/data/themedir1/block-theme/theme.json tests/phpunit/data/themedir1/block-theme/theme.json index 4961a620a2..52bb194b4a 100644
22 22 "slug": "custom-gradient" 23 23 } 24 24 ], 25 "duotone": [ 26 { 27 "colors": [ "#333333", "#aaaaaa" ], 28 "slug": "custom-duotone", 29 "name": "Custom Duotone" 30 } 31 ], 25 32 "custom": false, 26 33 "customGradient": false 27 34 }, … … 38 45 }, 39 46 "spacing": { 40 47 "units": ["rem"], 41 "customPadding": true 48 "customPadding": true, 49 "blockGap": true 42 50 }, 43 51 "blocks": { 44 52 "core/paragraph": { … … 54 62 } 55 63 } 56 64 }, 65 "styles" : { 66 "blocks" :{ 67 "core/post-featured-image": { 68 "shadow": "10px 10px 5px 0px rgba(0,0,0,0.66)", 69 "filter": { 70 "duotone": "var(--wp--preset--duotone--custom-duotone)" 71 } 72 } 73 }, 74 "elements": { 75 "button": { 76 "shadow": "10px 10px 5px 0px rgba(0,0,0,0.66)" 77 }, 78 "link": { 79 "typography": { 80 "textDecoration": "none" 81 }, 82 "border": { 83 "bottom": { 84 "width": "2px", 85 "color": "currentColor", 86 "style": "solid" 87 } 88 }, 89 ":hover": { 90 "typography": { 91 "textDecoration": "none" 92 }, 93 "border": { 94 "bottom": { 95 "width": "2px", 96 "color": "#000", 97 "style": "dotted" 98 } 99 } 100 } 101 } 102 } 103 }, 57 104 "customTemplates": [ 58 105 { 59 106 "name": "page-home", -
tests/phpunit/tests/theme/wpThemeJson.php
diff --git tests/phpunit/tests/theme/wpThemeJson.php tests/phpunit/tests/theme/wpThemeJson.php index 4cc81c98b2..7e7b439d97 100644
class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 431 431 /** 432 432 * @ticket 53175 433 433 * @ticket 54336 434 * @ticket 56611 434 435 */ 435 436 public function test_get_stylesheet() { 436 437 $theme_json = new WP_Theme_JSON( … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 438 439 'version' => WP_Theme_JSON::LATEST_SCHEMA, 439 440 'settings' => array( 440 441 'color' => array( 441 'text' => 'value',442 'palette' => array(442 'text' => 'value', 443 'palette' => array( 443 444 array( 444 445 'slug' => 'grey', 445 446 'color' => 'grey', 446 447 ), 447 448 ), 449 'gradients' => array( 450 array( 451 'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)', 452 'name' => 'Custom gradient', 453 'slug' => 'custom-gradient', 454 ), 455 ), 456 'duotone' => array( 457 array( 458 'colors' => array( '#333333', '#aaaaaa' ), 459 'name' => 'Custom Duotone', 460 'slug' => 'custom-duotone', 461 ), 462 ), 448 463 ), 449 464 'typography' => array( 450 465 'fontFamilies' => array( … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 478 493 ), 479 494 'misc' => 'value', 480 495 'elements' => array( 481 'link' => array(496 'link' => array( 482 497 'color' => array( 483 498 'text' => '#111', 484 499 'background' => '#333', 485 500 ), 486 501 ), 502 'button' => array( 503 'shadow' => '10px 10px 5px 0px rgba(0,0,0,0.66)', 504 ), 487 505 ), 488 506 'blocks' => array( 489 507 'core/group' => array( 508 'color' => array( 509 'gradient' => 'var:preset|gradient|custom-gradient', 510 ), 490 511 'border' => array( 491 512 'radius' => '10px', 492 513 ), … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 542 563 'bottom' => '30px', 543 564 ), 544 565 ), 566 'filter' => array( 567 'duotone' => 'var:preset|duotone|custom-duotone', 568 ), 545 569 ), 546 570 ), 547 571 'spacing' => array( … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 552 576 ) 553 577 ); 554 578 555 $variables = 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}';556 $styles = 'body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}.wp- block-group{border-radius: 10px;padding: 24px;}.wp-block-group a:where(:not(.wp-element-button)){color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a:where(:not(.wp-element-button)),h2 a:where(:not(.wp-element-button)),h3 a:where(:not(.wp-element-button)),h4 a:where(:not(.wp-element-button)),h5 a:where(:not(.wp-element-button)),h6 a:where(:not(.wp-element-button)){background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a:where(:not(.wp-element-button)){background-color: #777;color: #555;}.wp-block-image{margin-bottom: 30px;}.wp-block-image img, .wp-block-image .wp-block-image__crop-area{border-top-left-radius: 10px;border-bottom-right-radius: 1em;}';557 $presets = '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has- small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}';579 $variables = "body{--wp--preset--color--grey: grey;--wp--preset--gradient--custom-gradient: linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%);--wp--preset--duotone--custom-duotone: url('#wp-duotone-custom-duotone');--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}"; 580 $styles = 'body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}.wp-element-button, .wp-block-button__link{box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.66);}.wp-block-group{background: var(--wp--preset--gradient--custom-gradient);border-radius: 10px;padding: 24px;}.wp-block-group a:where(:not(.wp-element-button)){color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a:where(:not(.wp-element-button)),h2 a:where(:not(.wp-element-button)),h3 a:where(:not(.wp-element-button)),h4 a:where(:not(.wp-element-button)),h5 a:where(:not(.wp-element-button)),h6 a:where(:not(.wp-element-button)){background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a:where(:not(.wp-element-button)){background-color: #777;color: #555;}.wp-block-image{margin-bottom: 30px;}.wp-block-image img, .wp-block-image .components-placeholder{filter: var(--wp--preset--duotone--custom-duotone);}.wp-block-image img, .wp-block-image .wp-block-image__crop-area{border-top-left-radius: 10px;border-bottom-right-radius: 1em;}'; 581 $presets = '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-custom-gradient-gradient-background{background: var(--wp--preset--gradient--custom-gradient) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}'; 558 582 $all = $variables . $styles . $presets; 559 583 $this->assertSame( $all, $theme_json->get_stylesheet() ); 560 584 $this->assertSame( $styles, $theme_json->get_stylesheet( array( 'styles' ) ) ); … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 2945 2969 $this->assertEqualSetsWithIndex( $expected, $actual ); 2946 2970 } 2947 2971 2972 /** 2973 * @ticket 56611 2974 */ 2975 function test_export_data_sets_use_root_padding_aware_alignments() { 2976 $theme = new WP_Theme_JSON( 2977 array( 2978 'version' => 2, 2979 'settings' => array( 2980 'useRootPaddingAwareAlignments' => true, 2981 'blocks' => array( 2982 'core/paragraph' => array( 2983 'useRootPaddingAwareAlignments' => true, 2984 ), 2985 ), 2986 ), 2987 ) 2988 ); 2989 2990 $actual = $theme->get_data(); 2991 $expected = array( 2992 'version' => 2, 2993 'settings' => array( 2994 'useRootPaddingAwareAlignments' => true, 2995 'blocks' => array( 2996 'core/paragraph' => array( 2997 'useRootPaddingAwareAlignments' => true, 2998 ), 2999 ), 3000 ), 3001 ); 3002 3003 $this->assertEqualSetsWithIndex( $expected, $actual ); 3004 } 3005 3006 2948 3007 /** 2949 3008 * @ticket 56467 2950 3009 */ … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 3420 3479 ); 3421 3480 3422 3481 $metadata = array( 3423 'path' => array( 3424 '0' => 'styles', 3425 ), 3482 'path' => array( 'styles' ), 3426 3483 'selector' => 'body', 3427 3484 ); 3428 3485 … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 3453 3510 ); 3454 3511 3455 3512 $metadata = array( 3456 'path' => array( 3457 '0' => 'styles', 3458 ), 3513 'path' => array( 'styles' ), 3459 3514 'selector' => 'body', 3460 3515 ); 3461 3516 … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 3482 3537 ); 3483 3538 3484 3539 $metadata = array( 3485 'path' => array( 3486 '0' => 'settings', 3487 ), 3540 'path' => array( 'settings' ), 3488 3541 'selector' => 'body', 3489 3542 ); 3490 3543 … … class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 3494 3547 $this->assertSame( $expected, $root_rules . $style_rules ); 3495 3548 } 3496 3549 3550 /** 3551 * @ticket 56611 3552 */ 3553 function test_get_styles_with_appearance_tools() { 3554 $theme_json = new WP_Theme_JSON( 3555 array( 3556 'version' => 2, 3557 'settings' => array( 3558 'appearanceTools' => true, 3559 ), 3560 ) 3561 ); 3562 3563 $metadata = array( 3564 'path' => array( 'settings' ), 3565 'selector' => 'body', 3566 ); 3567 3568 $expected = 'body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }.wp-site-blocks > * + * { margin-block-start: ; }body { --wp--style--block-gap: ; }'; 3569 $root_rules = $theme_json->get_root_layout_rules( WP_Theme_JSON::ROOT_BLOCK_SELECTOR, $metadata ); 3570 $this->assertSame( $expected, $root_rules); 3571 } 3572 3497 3573 /** 3498 3574 * Tests generating the spacing presets array based on the spacing scale provided. 3499 3575 * -
tests/phpunit/tests/theme/wpThemeJsonResolver.php
diff --git tests/phpunit/tests/theme/wpThemeJsonResolver.php tests/phpunit/tests/theme/wpThemeJsonResolver.php index aa9c339e58..6c96305c43 100644
class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 76 76 /** 77 77 * @ticket 52991 78 78 * @ticket 54336 79 * @ticket 56611 79 80 */ 80 81 public function test_translations_are_applied() { 81 82 add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) ); … … class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 118 119 ), 119 120 ), 120 121 ), 122 'duotone' => array( 123 'theme' => array( 124 array( 125 'colors' => array( '#333333', '#aaaaaa' ), 126 'slug' => 'custom-duotone', 127 'name' => 'Custom Duotone', 128 ), 129 ), 130 ), 121 131 ), 122 132 'typography' => array( 123 133 'customFontSize' => false, … … class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 133 143 ), 134 144 ), 135 145 'spacing' => array( 136 'units' => array( 'rem' ), 137 'padding' => true, 146 'units' => array( 'rem' ), 147 'padding' => true, 148 'blockGap' => true, 138 149 ), 139 150 'blocks' => array( 140 151 'core/paragraph' => array( … … class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 244 255 245 256 /** 246 257 * @ticket 54336 258 * @ticket 56611 247 259 */ 248 260 function test_merges_child_theme_json_into_parent_theme_json() { 249 261 switch_theme( 'block-theme-child' ); … … class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 253 265 'color' => array( 254 266 'custom' => false, 255 267 'customGradient' => false, 268 'duotone' => array( 269 'theme' => array( 270 array( 271 'colors' => array( '#333333', '#aaaaaa' ), 272 'name' => 'Custom Duotone', 273 'slug' => 'custom-duotone', 274 ), 275 ), 276 ), 256 277 'gradients' => array( 257 278 'theme' => array( 258 279 array( … … class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 297 318 ), 298 319 ), 299 320 'spacing' => array( 300 'units' => array( 'rem' ), 301 'padding' => true, 321 'blockGap' => true, 322 'units' => array( 'rem' ), 323 'padding' => true, 302 324 ), 303 325 'blocks' => array( 304 326 'core/paragraph' => array(