<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[54443] trunk/tests/phpunit: Build/Test Tools: Expand unit tests for `theme.json`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/54443">54443</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/54443","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>audrasjb</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-10-10 14:52:21 +0000 (Mon, 10 Oct 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Build/Test Tools: Expand unit tests for `theme.json`.
This changeset adds unit test coverage for the following features:
- Gradients
- `filter` (Duotones)
- `blockGap`
- `shadow`
- `useRootPaddingAwareAlignments`
- `appearanceTools`
Props gunterer, johnregan3, audrasjb, mukesh27.
Fixes <a href="https://core.trac.wordpress.org/ticket/56611">#56611</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunitdatathemedir1blockthemethemejson">trunk/tests/phpunit/data/themedir1/block-theme/theme.json</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemeJsonphp">trunk/tests/phpunit/tests/theme/wpThemeJson.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemeJsonResolverphp">trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunitdatathemedir1blockthemethemejson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/themedir1/block-theme/theme.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/themedir1/block-theme/theme.json 2022-10-10 12:46:19 UTC (rev 54442)
+++ trunk/tests/phpunit/data/themedir1/block-theme/theme.json 2022-10-10 14:52:21 UTC (rev 54443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,6 +22,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "slug": "custom-gradient"
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ],
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "duotone": [
+ {
+ "colors": [ "#333333", "#aaaaaa" ],
+ "slug": "custom-duotone",
+ "name": "Custom Duotone"
+ }
+ ],
</ins><span class="cx" style="display: block; padding: 0 10px"> "custom": false,
</span><span class="cx" style="display: block; padding: 0 10px"> "customGradient": false
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,7 +45,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> "spacing": {
</span><span class="cx" style="display: block; padding: 0 10px"> "units": ["rem"],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "customPadding": true
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "customPadding": true,
+ "blockGap": true
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> "blocks": {
</span><span class="cx" style="display: block; padding: 0 10px"> "core/paragraph": {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -54,6 +62,45 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "styles" : {
+ "blocks" :{
+ "core/post-featured-image": {
+ "shadow": "10px 10px 5px 0px rgba(0,0,0,0.66)",
+ "filter": {
+ "duotone": "var(--wp--preset--duotone--custom-duotone)"
+ }
+ }
+ },
+ "elements": {
+ "button": {
+ "shadow": "10px 10px 5px 0px rgba(0,0,0,0.66)"
+ },
+ "link": {
+ "typography": {
+ "textDecoration": "none"
+ },
+ "border": {
+ "bottom": {
+ "width": "2px",
+ "color": "currentColor",
+ "style": "solid"
+ }
+ },
+ ":hover": {
+ "typography": {
+ "textDecoration": "none"
+ },
+ "border": {
+ "bottom": {
+ "width": "2px",
+ "color": "#000",
+ "style": "dotted"
+ }
+ }
+ }
+ }
+ }
+ },
</ins><span class="cx" style="display: block; padding: 0 10px"> "customTemplates": [
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> "name": "page-home",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,4 +119,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "area": "header"
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ]
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeJsonphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpThemeJson.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeJson.php 2022-10-10 12:46:19 UTC (rev 54442)
+++ trunk/tests/phpunit/tests/theme/wpThemeJson.php 2022-10-10 14:52:21 UTC (rev 54443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -431,6 +431,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 53175
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 54336
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 56611
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_stylesheet() {
</span><span class="cx" style="display: block; padding: 0 10px"> $theme_json = new WP_Theme_JSON(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -438,13 +439,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'version' => WP_Theme_JSON::LATEST_SCHEMA,
</span><span class="cx" style="display: block; padding: 0 10px"> 'settings' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'color' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'text' => 'value',
- 'palette' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'text' => 'value',
+ 'palette' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'grey',
</span><span class="cx" style="display: block; padding: 0 10px"> 'color' => 'grey',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'gradients' => array(
+ array(
+ 'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)',
+ 'name' => 'Custom gradient',
+ 'slug' => 'custom-gradient',
+ ),
+ ),
+ 'duotone' => array(
+ array(
+ 'colors' => array( '#333333', '#aaaaaa' ),
+ 'name' => 'Custom Duotone',
+ 'slug' => 'custom-duotone',
+ ),
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'typography' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'fontFamilies' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -478,15 +493,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'misc' => 'value',
</span><span class="cx" style="display: block; padding: 0 10px"> 'elements' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'link' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'link' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'color' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'text' => '#111',
</span><span class="cx" style="display: block; padding: 0 10px"> 'background' => '#333',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'button' => array(
+ 'shadow' => '10px 10px 5px 0px rgba(0,0,0,0.66)',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'blocks' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'core/group' => array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'color' => array(
+ 'gradient' => 'var:preset|gradient|custom-gradient',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'border' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'radius' => '10px',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -542,6 +563,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'bottom' => '30px',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'filter' => array(
+ 'duotone' => 'var:preset|duotone|custom-duotone',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'spacing' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -552,9 +576,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $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;}';
- $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-bl
ock-image .wp-block-image__crop-area{border-top-left-radius: 10px;border-bottom-right-radius: 1em;}';
- $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;}';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $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;}";
+ $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-bl
ock-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;}';
+ $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;}';
</ins><span class="cx" style="display: block; padding: 0 10px"> $all = $variables . $styles . $presets;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $all, $theme_json->get_stylesheet() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $styles, $theme_json->get_stylesheet( array( 'styles' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -676,7 +700,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-dark-grey-color{color: var(--wp--preset--color--dark-grey) !important;}.has-light-grey-color{color: var(--wp--preset--color--light-grey) !important;}.has-white-2-black-color{color: var(--wp--preset--color--white-2-black) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-dark-grey-background-color{background-color: var(--wp--preset--color--dark-grey) !important;}.has-light-grey-background-color{background-color: var(--wp--preset--color--light-grey) !important;}.has-white-2-black-background-color{background-color: var(--wp--preset--color--white-2-black) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-dark-grey-border-color{border-color: var(--wp--preset--color--dark-grey) !important;}.has-light-grey-border-color{border-color: var(--wp--preset--co
lor--light-grey) !important;}.has-white-2-black-border-color{border-color: var(--wp--preset--color--white-2-black) !important;}',
</span><span class="cx" style="display: block; padding: 0 10px"> $theme_json->get_stylesheet( array( 'presets' ) )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '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;}',
</span><span class="cx" style="display: block; padding: 0 10px"> $theme_json->get_stylesheet( array( 'variables' ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2947,6 +2970,41 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 56611
+ */
+ function test_export_data_sets_use_root_padding_aware_alignments() {
+ $theme = new WP_Theme_JSON(
+ array(
+ 'version' => 2,
+ 'settings' => array(
+ 'useRootPaddingAwareAlignments' => true,
+ 'blocks' => array(
+ 'core/paragraph' => array(
+ 'useRootPaddingAwareAlignments' => true,
+ ),
+ ),
+ ),
+ )
+ );
+
+ $actual = $theme->get_data();
+ $expected = array(
+ 'version' => 2,
+ 'settings' => array(
+ 'useRootPaddingAwareAlignments' => true,
+ 'blocks' => array(
+ 'core/paragraph' => array(
+ 'useRootPaddingAwareAlignments' => true,
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEqualSetsWithIndex( $expected, $actual );
+ }
+
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 56467
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_element_class_name_button() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3353,7 +3411,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'default'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals(
</ins><span class="cx" style="display: block; padding: 0 10px"> '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;}b
ody .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;}',
</span><span class="cx" style="display: block; padding: 0 10px"> $theme_json->get_stylesheet()
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3468,9 +3526,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'path' => array(
- '0' => 'styles',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'path' => array( 'styles' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'selector' => 'body',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3501,9 +3557,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'path' => array(
- '0' => 'styles',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'path' => array( 'styles' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'selector' => 'body',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3530,9 +3584,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'path' => array(
- '0' => 'settings',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'path' => array( 'settings' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'selector' => 'body',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3543,6 +3595,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 56611
+ */
+ function test_get_styles_with_appearance_tools() {
+ $theme_json = new WP_Theme_JSON(
+ array(
+ 'version' => 2,
+ 'settings' => array(
+ 'appearanceTools' => true,
+ ),
+ )
+ );
+
+ $metadata = array(
+ 'path' => array( 'settings' ),
+ 'selector' => 'body',
+ );
+
+ $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: ; }';
+ $root_rules = $theme_json->get_root_layout_rules( WP_Theme_JSON::ROOT_BLOCK_SELECTOR, $metadata );
+ $this->assertSame( $expected, $root_rules );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Tests generating the spacing presets array based on the spacing scale provided.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 56467
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3922,4 +3997,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeJsonResolverphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php 2022-10-10 12:46:19 UTC (rev 54442)
+++ trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php 2022-10-10 14:52:21 UTC (rev 54443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,6 +76,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 52991
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 54336
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 56611
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_translations_are_applied() {
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,6 +119,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'duotone' => array(
+ 'theme' => array(
+ array(
+ 'colors' => array( '#333333', '#aaaaaa' ),
+ 'slug' => 'custom-duotone',
+ 'name' => 'Custom Duotone',
+ ),
+ ),
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'typography' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'customFontSize' => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -133,8 +143,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'spacing' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'units' => array( 'rem' ),
- 'padding' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'units' => array( 'rem' ),
+ 'padding' => true,
+ 'blockGap' => true,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'blocks' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'core/paragraph' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -244,6 +255,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 54336
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 56611
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_merges_child_theme_json_into_parent_theme_json() {
</span><span class="cx" style="display: block; padding: 0 10px"> switch_theme( 'block-theme-child' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -253,6 +265,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'color' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'custom' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'customGradient' => false,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'duotone' => array(
+ 'theme' => array(
+ array(
+ 'colors' => array( '#333333', '#aaaaaa' ),
+ 'name' => 'Custom Duotone',
+ 'slug' => 'custom-duotone',
+ ),
+ ),
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'gradients' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'theme' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -297,8 +318,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'spacing' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'units' => array( 'rem' ),
- 'padding' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'blockGap' => true,
+ 'units' => array( 'rem' ),
+ 'padding' => true,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'blocks' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'core/paragraph' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -366,7 +388,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> WP_Theme_JSON_Resolver::clean_cached_data();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $query_count = count( $this->queries ) - $query_count;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $user_cpt );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -381,7 +403,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( $user_cpt, $new_user_cpt );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $query_count = count( $this->queries ) - $query_count;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' );
</ins><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'query', array( $this, 'filter_db_query' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -430,4 +452,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsArray( $post2 );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $post2 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>