Changeset 54443 for trunk/tests/phpunit/tests/theme/wpThemeJson.php
- Timestamp:
- 10/10/2022 02:52:21 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.