Changeset 54443
- Timestamp:
- 10/10/2022 02:52:21 PM (2 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/data/themedir1/block-theme/theme.json
r54184 r54443 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 … … 39 46 "spacing": { 40 47 "units": ["rem"], 41 "customPadding": true 48 "customPadding": true, 49 "blockGap": true 42 50 }, 43 51 "blocks": { … … 51 59 } 52 60 ] 61 } 62 } 63 } 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 } 53 100 } 54 101 } -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r54402 r54443 432 432 * @ticket 53175 433 433 * @ticket 54336 434 * @ticket 56611 434 435 */ 435 436 public function test_get_stylesheet() { … … 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', 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', 446 461 ), 447 462 ), … … 479 494 'misc' => 'value', 480 495 'elements' => array( 481 'link' => array(496 'link' => array( 482 497 'color' => array( 483 498 'text' => '#111', … … 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', … … 543 564 ), 544 565 ), 566 'filter' => array( 567 'duotone' => 'var:preset|duotone|custom-duotone', 568 ), 545 569 ), 546 570 ), … … 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() ); … … 677 701 $theme_json->get_stylesheet( array( 'presets' ) ) 678 702 ); 679 680 703 $this->assertSame( 681 704 'body{--wp--preset--color--grey: grey;--wp--preset--color--dark-grey: grey;--wp--preset--color--light-grey: grey;--wp--preset--color--white-2-black: grey;--wp--custom--white-2-black: value;}', … … 2948 2971 2949 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 3007 /** 2950 3008 * @ticket 56467 2951 3009 */ … … 3354 3412 ); 3355 3413 3356 $this->assert Same(3414 $this->assertEquals( 3357 3415 '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: 1rem; }body { --wp--style--block-gap: 1rem; }body .is-layout-flow > *{margin-block-start: 0;margin-block-end: 0;}body .is-layout-flow > * + *{margin-block-start: 1rem;margin-block-end: 0;}body .is-layout-flex{gap: 1rem;}body .is-layout-flow > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}body .is-layout-flow > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}body .is-layout-flow > .aligncenter{margin-left: auto !important;margin-right: auto !important;}body .is-layout-flex{display: flex;}body .is-layout-flex{flex-wrap: wrap;align-items: center;}.wp-block-post-content{color: gray;}.wp-block-social-links.is-layout-flow > *{margin-block-start: 0;margin-block-end: 0;}.wp-block-social-links.is-layout-flow > * + *{margin-block-start: 0;margin-block-end: 0;}.wp-block-social-links.is-layout-flex{gap: 0;}.wp-block-buttons.is-layout-flow > *{margin-block-start: 0;margin-block-end: 0;}.wp-block-buttons.is-layout-flow > * + *{margin-block-start: 0;margin-block-end: 0;}.wp-block-buttons.is-layout-flex{gap: 0;}', 3358 3416 $theme_json->get_stylesheet() … … 3469 3527 3470 3528 $metadata = array( 3471 'path' => array( 3472 '0' => 'styles', 3473 ), 3529 'path' => array( 'styles' ), 3474 3530 'selector' => 'body', 3475 3531 ); … … 3502 3558 3503 3559 $metadata = array( 3504 'path' => array( 3505 '0' => 'styles', 3506 ), 3560 'path' => array( 'styles' ), 3507 3561 'selector' => 'body', 3508 3562 ); … … 3531 3585 3532 3586 $metadata = array( 3533 'path' => array( 3534 '0' => 'settings', 3535 ), 3587 'path' => array( 'settings' ), 3536 3588 'selector' => 'body', 3537 3589 ); … … 3541 3593 $style_rules = $theme_json->get_styles_for_block( $metadata ); 3542 3594 $this->assertSame( $expected, $root_rules . $style_rules ); 3595 } 3596 3597 /** 3598 * @ticket 56611 3599 */ 3600 function test_get_styles_with_appearance_tools() { 3601 $theme_json = new WP_Theme_JSON( 3602 array( 3603 'version' => 2, 3604 'settings' => array( 3605 'appearanceTools' => true, 3606 ), 3607 ) 3608 ); 3609 3610 $metadata = array( 3611 'path' => array( 'settings' ), 3612 'selector' => 'body', 3613 ); 3614 3615 $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: ; }'; 3616 $root_rules = $theme_json->get_root_layout_rules( WP_Theme_JSON::ROOT_BLOCK_SELECTOR, $metadata ); 3617 $this->assertSame( $expected, $root_rules ); 3543 3618 } 3544 3619 -
trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php
r54402 r54443 77 77 * @ticket 52991 78 78 * @ticket 54336 79 * @ticket 56611 79 80 */ 80 81 public function test_translations_are_applied() { … … 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( … … 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( … … 245 256 /** 246 257 * @ticket 54336 258 * @ticket 56611 247 259 */ 248 260 function test_merges_child_theme_json_into_parent_theme_json() { … … 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( … … 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( … … 367 389 } 368 390 $query_count = count( $this->queries ) - $query_count; 369 $this->assert Same( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' );391 $this->assertEquals( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' ); 370 392 371 393 $user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme ); … … 382 404 } 383 405 $query_count = count( $this->queries ) - $query_count; 384 $this->assert Same( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' );406 $this->assertEquals( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' ); 385 407 remove_filter( 'query', array( $this, 'filter_db_query' ) ); 386 408 }
Note: See TracChangeset
for help on using the changeset viewer.