<!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>[50967] trunk: Docs: Some documentation and test improvements for `WP_Theme_JSON` and `WP_Theme_JSON_Resolver` classes:</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/50967">50967</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/50967","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-05-24 13:24:05 +0000 (Mon, 24 May 2021)</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'>Docs: Some documentation and test improvements for `WP_Theme_JSON` and `WP_Theme_JSON_Resolver` classes:

* Add missing `@since` tags.
* Update some DocBlocks per the documentation standards.
* Rename test files and classes per the naming conventions.
* Fix some code alignment issues reported by WPCS.

Follow-up to <a href="https://core.trac.wordpress.org/changeset/50959">[50959]</a>, <a href="https://core.trac.wordpress.org/changeset/50960">[50960]</a>.

See <a href="https://core.trac.wordpress.org/ticket/52991">#52991</a>, <a href="https://core.trac.wordpress.org/ticket/53175">#53175</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpthemejsonresolverphp">trunk/src/wp-includes/class-wp-theme-json-resolver.php</a></li>
<li><a href="#trunksrcwpincludesclasswpthemejsonphp">trunk/src/wp-includes/class-wp-theme-json.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunitteststhemewpThemephp">trunk/tests/phpunit/tests/theme/wpTheme.php</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>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunitteststhemeWPThemephp">trunk/tests/phpunit/tests/theme/WPTheme.php</a></li>
<li><a href="#trunktestsphpunitteststhemeclasswpthemejsonresolverphp">trunk/tests/phpunit/tests/theme/class-wp-theme-json-resolver.php</a></li>
<li><a href="#trunktestsphpunitteststhemeclasswpthemejsonphp">trunk/tests/phpunit/tests/theme/class-wp-theme-json.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpthemejsonresolverphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-theme-json-resolver.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-theme-json-resolver.php    2021-05-24 12:27:35 UTC (rev 50966)
+++ trunk/src/wp-includes/class-wp-theme-json-resolver.php      2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,14 +1,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Process the different data sources for site-level
- * config and offers and API to work with them.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * WP_Theme_JSON_Resolver class
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @package WordPress
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @subpackage Theme
+ * @since 5.8.0
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Class that abstracts the processing
- * of the different data sources.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Class that abstracts the processing of the different data sources
+ * for site-level config and offers an API to work with them.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,6 +18,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Container for data coming from core.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
</ins><span class="cx" style="display: block; padding: 0 10px">          * @var WP_Theme_JSON
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static $core = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,6 +26,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Container for data coming from the theme.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
</ins><span class="cx" style="display: block; padding: 0 10px">          * @var WP_Theme_JSON
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static $theme = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,7 +34,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Whether or not the theme supports theme.json.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @var boolean
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 5.8.0
+        * @var bool
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        private static $theme_has_support = null;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,17 +42,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Structure to hold i18n metadata.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @var Array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 5.8.0
+        * @var array
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        private static $theme_json_i18n = null;
</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">-         * Processes a file that adheres to the theme.json
-        * schema and returns an array with its contents,
-        * or a void array if none found.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Processes a file that adheres to the theme.json schema
+        * and returns an array with its contents, or a void array if none found.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param string $file_path Path to file. Empty if no file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return array Contents that adhere to the theme.json schema.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function read_json_file( $file_path ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,35 +83,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * For example, given this input:
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * {
-        *   "settings": {
-        *     "*": {
-        *       "typography": {
-        *         "fontSizes": [ { "name": "Font size name" } ],
-        *         "fontStyles": [ { "name": "Font size name" } ]
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *     {
+        *       "settings": {
+        *         "*": {
+        *           "typography": {
+        *             "fontSizes": [ { "name": "Font size name" } ],
+        *             "fontStyles": [ { "name": "Font size name" } ]
+        *           }
+        *         }
</ins><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><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * will return this output:
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * [
-        *   0 => [
-        *     'path'    => [ 'settings', '*', 'typography', 'fontSizes' ],
-        *     'key'     => 'name',
-        *     'context' => 'Font size name'
-        *   ],
-        *   1 => [
-        *     'path'    => [ 'settings', '*', 'typography', 'fontStyles' ],
-        *     'key'     => 'name',
-        *     'context' => 'Font style name'
-        *   ]
-        * ]
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *     [
+        *       0 => [
+        *         'path'    => [ 'settings', '*', 'typography', 'fontSizes' ],
+        *         'key'     => 'name',
+        *         'context' => 'Font size name'
+        *       ],
+        *       1 => [
+        *         'path'    => [ 'settings', '*', 'typography', 'fontStyles' ],
+        *         'key'     => 'name',
+        *         'context' => 'Font style name'
+        *       ]
+        *     ]
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array $i18n_partial A tree that follows the format of i18n-theme.json.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $current_path Keeps track of the path as we walk down the given tree.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return array A linear array containing the paths to translate.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function extract_paths_to_translate( $i18n_partial, $current_path = array() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,7 +140,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Returns a data structure used in theme.json translation.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @return array An array of theme.json fields that are translatable and the keys that are translatable
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 5.8.0
+        *
+        * @return array An array of theme.json fields that are translatable and the keys that are translatable.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function get_fields_to_translate() {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( null === self::$theme_json_i18n ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,11 +155,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Translates a chunk of the loaded theme.json structure.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array  $array_to_translate The chunk of theme.json to translate.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $key                The key of the field that contains the string to translate.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $context            The context to apply in the translation call.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return array Returns the modified $theme_json chunk.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function translate_theme_json_chunk( array $array_to_translate, $key, $context, $domain ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,14 +177,14 @@
</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">-         * Given a theme.json structure modifies it in place
-        * to update certain values by its translated strings
-        * according to the language set by the user.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Given a theme.json structure modifies it in place to update certain values
+        * by its translated strings according to the language set by the user.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array  $theme_json The theme.json to translate.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @param string $domain    Optional. Text domain. Unique identifier for retrieving translated strings.
-        *                          Default 'default'.
-        *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @param string $domain     Optional. Text domain. Unique identifier for retrieving translated strings.
+        *                           Default 'default'.
</ins><span class="cx" style="display: block; padding: 0 10px">          * @return array Returns the modified $theme_json_structure.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function translate( $theme_json, $domain = 'default' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -228,6 +237,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Return core's origin config.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @return WP_Theme_JSON Entity that holds core data.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function get_core_data() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -245,16 +256,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Returns the theme's data.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Data from theme.json can be augmented via the
-        * $theme_support_data variable. This is useful, for example,
-        * to backfill the gaps in theme.json that a theme has declared
-        * via add_theme_supports.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Data from theme.json can be augmented via the $theme_support_data variable.
+        * This is useful, for example, to backfill the gaps in theme.json that a theme
+        * has declared via add_theme_supports.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Note that if the same data is present in theme.json
-        * and in $theme_support_data, the theme.json's is not overwritten.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Note that if the same data is present in theme.json and in $theme_support_data,
+        * the theme.json's is not overwritten.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array $theme_support_data Theme support data in theme.json format.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return WP_Theme_JSON Entity that holds theme data.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function get_theme_data( $theme_support_data = array() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -279,22 +290,19 @@
</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">-         * There are different sources of data for a site:
-        * core and theme.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * There are different sources of data for a site: core and theme.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * While the getters {@link get_core_data},
-        * {@link get_theme_data} return the raw data
-        * from the respective origins, this method merges them
-        * all together.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * While the getters {@link get_core_data}, {@link get_theme_data} return the raw data
+        * from the respective origins, this method merges them all together.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * If the same piece of data is declared in different origins (core and theme),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * the last origin overrides the previous. For example,
-        * if core disables custom colors but a theme enables them,
-        * the theme config wins.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * the last origin overrides the previous. For example, if core disables custom colors
+        * but a theme enables them, the theme config wins.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array  $settings Existing block editor settings.
</span><span class="cx" style="display: block; padding: 0 10px">         *                         Empty array by default.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return WP_Theme_JSON
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function get_merged_data( $settings = array() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -321,24 +329,23 @@
</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">-         * Builds the path to the given file
-        * and checks that it is readable.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Builds the path to the given file and checks that it is readable.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * If it isn't, returns an empty string,
-        * otherwise returns the whole file path.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * If it isn't, returns an empty string, otherwise returns the whole file path.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param string $file_name Name of the file.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string The whole file path or empty if the file doesn't exist.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function get_file_path_from_theme( $file_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // This used to be a locate_template call.
-               // However, that method proved problematic
-               // due to its use of constants (STYLESHEETPATH)
-               // that threw errors in some scenarios.
-               //
-               // When the theme.json merge algorithm properly supports
-               // child themes, this should also fallback
-               // to the template path, as locate_template did.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * This used to be a locate_template call. However, that method proved problematic
+                * due to its use of constants (STYLESHEETPATH) that threw errors in some scenarios.
+                *
+                * When the theme.json merge algorithm properly supports child themes,
+                * this should also fall back to the template path, as locate_template did.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 $located   = '';
</span><span class="cx" style="display: block; padding: 0 10px">                $candidate = get_stylesheet_directory() . '/' . $file_name;
</span><span class="cx" style="display: block; padding: 0 10px">                if ( is_readable( $candidate ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -349,12 +356,14 @@
</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">         * Cleans the cached data so it can be recalculated.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         *
+        * @since 5.8.0
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function clean_cached_data() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                self::$core                     = null;
-               self::$theme                    = null;
-               self::$theme_has_support        = null;
-               self::$theme_json_i18n          = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         self::$core              = null;
+               self::$theme             = null;
+               self::$theme_has_support = null;
+               self::$theme_json_i18n   = null;
</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"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpthemejsonphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-theme-json.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-theme-json.php     2021-05-24 12:27:35 UTC (rev 50966)
+++ trunk/src/wp-includes/class-wp-theme-json.php       2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,13 +1,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Process of structures that adhere to the theme.json schema.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * WP_Theme_JSON class
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @package WordPress
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @subpackage Theme
+ * @since 5.8.0
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Class that encapsulates the processing of
- * structures that adhere to the theme.json spec.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Class that encapsulates the processing of structures that adhere to the theme.json spec.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,6 +17,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Container of data in theme.json format.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
</ins><span class="cx" style="display: block; padding: 0 10px">          * @var array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private $theme_json = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,6 +26,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * Holds the allowed block names extracted from block.json.
</span><span class="cx" style="display: block; padding: 0 10px">         * Shared among all instances so we only process it once.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
</ins><span class="cx" style="display: block; padding: 0 10px">          * @var array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static $allowed_block_names = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,6 +65,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array $theme_json A structure that follows the theme.json schema.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function __construct( $theme_json = array() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -70,12 +75,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</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->theme_json  = self::sanitize( $theme_json );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->theme_json = self::sanitize( $theme_json );
</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">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Returns the allowed block names.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @return array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function get_allowed_block_names() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,8 +98,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Sanitizes the input according to the schemas.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array $input Structure to sanitize.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return array The sanitized output.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function sanitize( $input ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,9 +151,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * It is recursive and modifies the input in-place.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array $tree Input to process.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array $schema Schema to adhere to.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return array Returns the modified $tree.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function remove_keys_not_in_schema( $tree, $schema ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -175,19 +184,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * Example:
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * {
-        *   'root': {
-        *     'color': {
-        *       'custom': true
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *     {
+        *       'root': {
+        *         'color': {
+        *           'custom': true
+        *         }
+        *       },
+        *       'core/paragraph': {
+        *         'spacing': {
+        *           'customPadding': true
+        *         }
+        *       }
</ins><span class="cx" style="display: block; padding: 0 10px">          *     }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *   },
-        *   'core/paragraph': {
-        *     'spacing': {
-        *       'customPadding': true
-        *     }
-        *   }
-        * }
</del><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @return array Settings per block.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function get_settings() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -201,17 +212,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Builds metadata for the setting nodes, which returns in the form of:
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * [
-        *   [
-        *     'path' => ['path', 'to', 'some', 'node' ]
-        *   ],
-        *   [
-        *     'path' => [ 'path', 'to', 'other', 'node' ]
-        *   ],
-        * ]
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *     [
+        *       [
+        *         'path' => ['path', 'to', 'some', 'node' ]
+        *       ],
+        *       [
+        *         'path' => [ 'path', 'to', 'other', 'node' ]
+        *       ],
+        *     ]
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array $theme_json The tree to extract setting nodes from.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static function get_setting_nodes( $theme_json ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,6 +254,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Merge new incoming data.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param WP_Theme_JSON $incoming Data to merge.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function merge( $incoming ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -248,11 +262,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $incoming_data    = $incoming->get_raw_data();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // The array_replace_recursive algorithm merges at the leaf level.
-               // For leaf values that are arrays it will use the numeric indexes for replacement.
-               // In those cases, what we want is to use the incoming value, if it exists.
-               //
-               // These are the cases that have array values at the leaf levels.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * The array_replace_recursive algorithm merges at the leaf level.
+                * For leaf values that are arrays it will use the numeric indexes for replacement.
+                * In those cases, what we want is to use the incoming value, if it exists.
+                *
+                * These are the cases that have array values at the leaf levels.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 $properties   = array();
</span><span class="cx" style="display: block; padding: 0 10px">                $properties[] = array( 'color', 'palette' );
</span><span class="cx" style="display: block; padding: 0 10px">                $properties[] = array( 'color', 'gradients' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -277,6 +293,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Returns the raw data.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @return array Raw data.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function get_raw_data() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,12 +302,12 @@
</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><span class="cx" style="display: block; padding: 0 10px">          * Transforms the given editor settings according the
</span><span class="cx" style="display: block; padding: 0 10px">         * add_theme_support format to the theme.json format.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 5.8.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param array $settings Existing editor settings.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
</del><span class="cx" style="display: block; padding: 0 10px">          * @return array Config that adheres to the theme.json schema.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function get_from_editor_settings( $settings ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -364,10 +382,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $theme_settings['settings']['typography']['fontSizes'] = $font_sizes;
</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 allows to make the plugin work with WordPress 5.7 beta
-               // as well as lower versions. The second check can be removed
-               // as soon as the minimum WordPress version for the plugin
-               // is bumped to 5.7.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * This allows to make the plugin work with WordPress 5.8 beta
+                * as well as lower versions. The second check can be removed
+                * as soon as the minimum WordPress version for the plugin
+                * is bumped to 5.8.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( isset( $settings['enableCustomSpacing'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( ! isset( $theme_settings['settings']['spacing'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $theme_settings['settings']['spacing'] = array();
</span></span></pre></div>
<a id="trunktestsphpunitteststhemeWPThemephp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/theme/WPTheme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/WPTheme.php       2021-05-24 12:27:35 UTC (rev 50966)
+++ trunk/tests/phpunit/tests/theme/WPTheme.php 2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,241 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * @group themes
- */
-class Tests_Theme_WPTheme extends WP_UnitTestCase {
-       function setUp() {
-               parent::setUp();
-               $this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
-
-               $this->orig_theme_dir            = $GLOBALS['wp_theme_directories'];
-               $GLOBALS['wp_theme_directories'] = array( $this->theme_root );
-
-               add_filter( 'theme_root', array( $this, '_theme_root' ) );
-               add_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
-               add_filter( 'template_root', array( $this, '_theme_root' ) );
-               // Clear caches.
-               wp_clean_themes_cache();
-               unset( $GLOBALS['wp_themes'] );
-       }
-
-       function tearDown() {
-               $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
-               wp_clean_themes_cache();
-               unset( $GLOBALS['wp_themes'] );
-               parent::tearDown();
-       }
-
-       // Replace the normal theme root directory with our premade test directory.
-       function _theme_root( $dir ) {
-               return $this->theme_root;
-       }
-       function test_new_WP_Theme_top_level() {
-               $theme = new WP_Theme( 'theme1', $this->theme_root );
-
-               // Meta.
-               $this->assertSame( 'My Theme', $theme->get( 'Name' ) );
-               $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) );
-               $this->assertSame( 'An example theme', $theme->get( 'Description' ) );
-               $this->assertSame( 'Minnie Bannister', $theme->get( 'Author' ) );
-               $this->assertSame( 'http://example.com/', $theme->get( 'AuthorURI' ) );
-               $this->assertSame( '1.3', $theme->get( 'Version' ) );
-               $this->assertSame( '', $theme->get( 'Template' ) );
-               $this->assertSame( 'publish', $theme->get( 'Status' ) );
-               $this->assertSame( array(), $theme->get( 'Tags' ) );
-
-               // Important.
-               $this->assertSame( 'theme1', $theme->get_stylesheet() );
-               $this->assertSame( 'theme1', $theme->get_template() );
-       }
-
-       function test_new_WP_Theme_subdir() {
-               $theme = new WP_Theme( 'subdir/theme2', $this->theme_root );
-
-               // Meta.
-               $this->assertSame( 'My Subdir Theme', $theme->get( 'Name' ) );
-               $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) );
-               $this->assertSame( 'An example theme in a sub directory', $theme->get( 'Description' ) );
-               $this->assertSame( 'Mr. WordPress', $theme->get( 'Author' ) );
-               $this->assertSame( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) );
-               $this->assertSame( '0.1', $theme->get( 'Version' ) );
-               $this->assertSame( '', $theme->get( 'Template' ) );
-               $this->assertSame( 'publish', $theme->get( 'Status' ) );
-               $this->assertSame( array(), $theme->get( 'Tags' ) );
-
-               // Important.
-               $this->assertSame( 'subdir/theme2', $theme->get_stylesheet() );
-               $this->assertSame( 'subdir/theme2', $theme->get_template() );
-       }
-
-       /**
-        * @ticket 20313
-        */
-       function test_new_WP_Theme_subdir_bad_root() {
-               // This is what get_theme_data() does when you pass it a style.css file for a theme in a subdirectory.
-               $theme = new WP_Theme( 'theme2', $this->theme_root . '/subdir' );
-
-               // Meta.
-               $this->assertSame( 'My Subdir Theme', $theme->get( 'Name' ) );
-               $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) );
-               $this->assertSame( 'An example theme in a sub directory', $theme->get( 'Description' ) );
-               $this->assertSame( 'Mr. WordPress', $theme->get( 'Author' ) );
-               $this->assertSame( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) );
-               $this->assertSame( '0.1', $theme->get( 'Version' ) );
-               $this->assertSame( '', $theme->get( 'Template' ) );
-               $this->assertSame( 'publish', $theme->get( 'Status' ) );
-               $this->assertSame( array(), $theme->get( 'Tags' ) );
-
-               // Important.
-               $this->assertSame( 'subdir/theme2', $theme->get_stylesheet() );
-               $this->assertSame( 'subdir/theme2', $theme->get_template() );
-       }
-
-       /**
-        * @ticket 21749
-        */
-       function test_wp_theme_uris_with_spaces() {
-               $theme = new WP_Theme( 'theme with spaces', $this->theme_root . '/subdir' );
-               // Make sure subdir/ is considered part of the stylesheet, as we must avoid encoding /'s.
-               $this->assertSame( 'subdir/theme with spaces', $theme->get_stylesheet() );
-
-               // Check that in a URI path, we have raw URL encoding (spaces become %20).
-               // Don't try to verify the complete URI path. get_theme_root_uri() breaks down quickly.
-               $this->assertSame( 'theme%20with%20spaces', basename( $theme->get_stylesheet_directory_uri() ) );
-               $this->assertSame( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) );
-
-               // Check that wp_customize_url() uses URL encoding, as it is a query arg (spaces become +).
-               $this->assertSame( admin_url( 'customize.php?theme=theme+with+spaces' ), wp_customize_url( 'theme with spaces' ) );
-       }
-
-       /**
-        * @ticket 21969
-        */
-       function test_theme_uris_with_spaces() {
-               $callback = array( $this, 'filter_theme_with_spaces' );
-               add_filter( 'stylesheet', $callback );
-               add_filter( 'template', $callback );
-
-               $this->assertSame( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_stylesheet_directory_uri() );
-               $this->assertSame( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_template_directory_uri() );
-
-               remove_filter( 'stylesheet', $callback );
-               remove_filter( 'template', $callback );
-       }
-
-       function filter_theme_with_spaces() {
-               return 'subdir/theme with spaces';
-       }
-
-       /**
-        * @ticket 26873
-        */
-       function test_display_method_on_get_method_failure() {
-               $theme = new WP_Theme( 'nonexistent', $this->theme_root );
-               $this->assertSame( 'nonexistent', $theme->get( 'Name' ) );
-               $this->assertFalse( $theme->get( 'AuthorURI' ) );
-               $this->assertFalse( $theme->get( 'Tags' ) );
-               $this->assertFalse( $theme->display( 'Tags' ) );
-       }
-
-       /**
-        * @ticket 40820
-        */
-       function test_child_theme_with_itself_as_parent_should_appear_as_broken() {
-               $theme  = new WP_Theme( 'child-parent-itself', $this->theme_root );
-               $errors = $theme->errors();
-               $this->assertWPError( $errors );
-               $this->assertSame( 'theme_child_invalid', $errors->get_error_code() );
-       }
-
-
-       /**
-        * Enable a single theme on a network.
-        *
-        * @ticket 30594
-        * @group ms-required
-        */
-       function test_wp_theme_network_enable_single_theme() {
-               $theme                  = 'testtheme-1';
-               $current_allowed_themes = get_site_option( 'allowedthemes' );
-               WP_Theme::network_enable_theme( $theme );
-               $new_allowed_themes = get_site_option( 'allowedthemes' );
-               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
-               $current_allowed_themes['testtheme-1'] = true; // Add the new theme to the previous set.
-
-               $this->assertSameSetsWithIndex( $current_allowed_themes, $new_allowed_themes );
-       }
-
-       /**
-        * Enable multiple themes on a network.
-        *
-        * @ticket 30594
-        * @group ms-required
-        */
-       function test_wp_theme_network_enable_multiple_themes() {
-               $themes                 = array( 'testtheme-2', 'testtheme-3' );
-               $current_allowed_themes = get_site_option( 'allowedthemes' );
-               WP_Theme::network_enable_theme( $themes );
-               $new_allowed_themes = get_site_option( 'allowedthemes' );
-               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
-               $current_allowed_themes = array_merge(
-                       $current_allowed_themes,
-                       array(
-                               'testtheme-2' => true,
-                               'testtheme-3' => true,
-                       )
-               );
-
-               $this->assertSameSetsWithIndex( $current_allowed_themes, $new_allowed_themes );
-       }
-
-       /**
-        * Disable a single theme on a network.
-        *
-        * @ticket 30594
-        * @group ms-required
-        */
-       function test_network_disable_single_theme() {
-               $current_allowed_themes = get_site_option( 'allowedthemes' );
-
-               $allowed_themes = array(
-                       'existing-1' => true,
-                       'existing-2' => true,
-                       'existing-3' => true,
-               );
-               update_site_option( 'allowedthemes', $allowed_themes );
-
-               $disable_theme = 'existing-2';
-               WP_Theme::network_disable_theme( $disable_theme );
-               $new_allowed_themes = get_site_option( 'allowedthemes' );
-               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
-               unset( $allowed_themes[ $disable_theme ] ); // Remove deleted theme from initial set.
-
-               $this->assertSameSetsWithIndex( $allowed_themes, $new_allowed_themes );
-       }
-
-       /**
-        * Disable multiple themes on a network.
-        *
-        * @ticket 30594
-        * @group ms-required
-        */
-       function test_network_disable_multiple_themes() {
-               $current_allowed_themes = get_site_option( 'allowedthemes' );
-
-               $allowed_themes = array(
-                       'existing-4' => true,
-                       'existing-5' => true,
-                       'existing-6' => true,
-               );
-               update_site_option( 'allowedthemes', $allowed_themes );
-
-               $disable_themes = array( 'existing-4', 'existing-5' );
-               WP_Theme::network_disable_theme( $disable_themes );
-               $new_allowed_themes = get_site_option( 'allowedthemes' );
-               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
-               unset( $allowed_themes['existing-4'] );
-               unset( $allowed_themes['existing-5'] );
-
-               $this->assertSameSetsWithIndex( $allowed_themes, $new_allowed_themes );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunitteststhemeclasswpthemejsonresolverphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/theme/class-wp-theme-json-resolver.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/class-wp-theme-json-resolver.php  2021-05-24 12:27:35 UTC (rev 50966)
+++ trunk/tests/phpunit/tests/theme/class-wp-theme-json-resolver.php    2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,157 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-/**
- * Test WP_Theme_JSON_Resolver class.
- *
- * @package WordPress
- * @since 5.8.0
- */
-
-class WP_Theme_JSON_Resolver_Test extends WP_UnitTestCase {
-
-       function setUp() {
-               parent::setUp();
-               $this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
-
-               $this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
-
-               // /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
-               $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
-
-               add_filter( 'theme_root', array( $this, 'filter_set_theme_root' ) );
-               add_filter( 'stylesheet_root', array( $this, 'filter_set_theme_root' ) );
-               add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) );
-               // Clear caches.
-               wp_clean_themes_cache();
-               unset( $GLOBALS['wp_themes'] );
-       }
-
-       function tearDown() {
-               $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
-               wp_clean_themes_cache();
-               unset( $GLOBALS['wp_themes'] );
-               parent::tearDown();
-       }
-
-       function filter_set_theme_root() {
-               return $this->theme_root;
-       }
-
-       function filter_set_locale_to_polish() {
-               return 'pl_PL';
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_fields_are_extracted() {
-               $actual = WP_Theme_JSON_Resolver::get_fields_to_translate();
-
-               $expected = array(
-                       array(
-                               'path'    => array( 'settings', 'typography', 'fontSizes' ),
-                               'key'     => 'name',
-                               'context' => 'Font size name',
-                       ),
-                       array(
-                               'path'    => array( 'settings', 'color', 'palette' ),
-                               'key'     => 'name',
-                               'context' => 'Color name',
-                       ),
-                       array(
-                               'path'    => array( 'settings', 'color', 'gradients' ),
-                               'key'     => 'name',
-                               'context' => 'Gradient name',
-                       ),
-                       array(
-                               'path'    => array( 'settings', 'color', 'duotone' ),
-                               'key'     => 'name',
-                               'context' => 'Duotone name',
-                       ),
-                       array(
-                               'path'    => array( 'settings', 'blocks', '*', 'typography', 'fontSizes' ),
-                               'key'     => 'name',
-                               'context' => 'Font size name',
-                       ),
-                       array(
-                               'path'    => array( 'settings', 'blocks', '*', 'color', 'palette' ),
-                               'key'     => 'name',
-                               'context' => 'Color name',
-                       ),
-                       array(
-                               'path'    => array( 'settings', 'blocks', '*', 'color', 'gradients' ),
-                               'key'     => 'name',
-                               'context' => 'Gradient name',
-                       ),
-               );
-
-               $this->assertEquals( $expected, $actual );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_translations_are_applied() {
-               add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
-               load_textdomain( 'fse', realpath( DIR_TESTDATA . '/languages/themes/fse-pl_PL.mo' ) );
-
-               switch_theme( 'fse' );
-
-               $actual = WP_Theme_JSON_Resolver::get_theme_data();
-
-               unload_textdomain( 'fse' );
-               remove_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
-
-               $this->assertSame( wp_get_theme()->get( 'TextDomain' ), 'fse' );
-               $this->assertSame(
-                       array(
-                               'color'  => array(
-                                       'palette' => array(
-                                               array(
-                                                       'slug'  => 'light',
-                                                       'name'  => 'Jasny',
-                                                       'color' => '#f5f7f9',
-                                               ),
-                                               array(
-                                                       'slug'  => 'dark',
-                                                       'name'  => 'Ciemny',
-                                                       'color' => '#000',
-                                               ),
-                                       ),
-                                       'custom'  => false,
-                               ),
-                               'blocks' => array(
-                                       'core/paragraph' => array(
-                                               'color' => array(
-                                                       'palette' => array(
-                                                               array(
-                                                                       'slug'  => 'light',
-                                                                       'name'  => 'Jasny',
-                                                                       'color' => '#f5f7f9',
-                                                               ),
-                                                       ),
-                                               ),
-                                       ),
-                               ),
-                       ),
-                       $actual->get_settings()
-               );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_switching_themes_recalculates_data() {
-               // By default, the theme for unit tests is "default",
-               // which doesn't have theme.json support.
-               $default = WP_Theme_JSON_Resolver::theme_has_support();
-
-               // Switch to a theme that does have support.
-               switch_theme( 'fse' );
-               $fse = WP_Theme_JSON_Resolver::theme_has_support();
-
-               $this->assertSame( false, $default );
-               $this->assertSame( true, $fse );
-       }
-
-}
</del></span></pre></div>
<a id="trunktestsphpunitteststhemeclasswpthemejsonphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/theme/class-wp-theme-json.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/class-wp-theme-json.php   2021-05-24 12:27:35 UTC (rev 50966)
+++ trunk/tests/phpunit/tests/theme/class-wp-theme-json.php     2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,464 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-/**
- * Test WP_Theme_JSON class.
- *
- * @package WordPress
- * @since 5.8.0
- */
-
-class WP_Theme_JSON_Test extends WP_UnitTestCase {
-
-       /**
-        * @ticket 52991
-        */
-       function test_get_settings() {
-               $theme_json = new WP_Theme_JSON(
-                       array(
-                               'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                               'settings' => array(
-                                       'color'       => array(
-                                               'custom' => false,
-                                       ),
-                                       'invalid/key' => 'value',
-                                       'blocks'      => array(
-                                               'core/group' => array(
-                                                       'color'       => array(
-                                                               'custom' => false,
-                                                       ),
-                                                       'invalid/key' => 'value',
-                                               ),
-                                       ),
-                               ),
-                               'styles'   => array(
-                                       'color' => array(
-                                               'link' => 'blue',
-                                       ),
-                               ),
-                       )
-               );
-
-               $actual = $theme_json->get_settings();
-
-               $expected = array(
-                       'color'  => array(
-                               'custom' => false,
-                       ),
-                       'blocks' => array(
-                               'core/group' => array(
-                                       'color' => array(
-                                               'custom' => false,
-                                       ),
-                               ),
-                       ),
-               );
-
-               $this->assertEqualSetsWithIndex( $expected, $actual );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_merge_incoming_data() {
-               $initial = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'color'  => array(
-                                       'custom'  => false,
-                                       'palette' => array(
-                                               array(
-                                                       'slug'  => 'red',
-                                                       'color' => 'red',
-                                               ),
-                                               array(
-                                                       'slug'  => 'green',
-                                                       'color' => 'green',
-                                               ),
-                                       ),
-                               ),
-                               'blocks' => array(
-                                       'core/paragraph' => array(
-                                               'color' => array(
-                                                       'custom' => false,
-                                               ),
-                                       ),
-                               ),
-                       ),
-                       'styles'   => array(
-                               'typography' => array(
-                                       'fontSize' => '12',
-                               ),
-                       ),
-               );
-
-               $add_new_block = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'blocks' => array(
-                                       'core/list' => array(
-                                               'color' => array(
-                                                       'custom' => false,
-                                               ),
-                                       ),
-                               ),
-                       ),
-                       'styles'   => array(
-                               'blocks' => array(
-                                       'core/list' => array(
-                                               'typography' => array(
-                                                       'fontSize' => '12',
-                                               ),
-                                               'color'      => array(
-                                                       'background' => 'brown',
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
-
-               $add_key_in_settings = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'color' => array(
-                                       'customGradient' => true,
-                               ),
-                       ),
-               );
-
-               $update_key_in_settings = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'color' => array(
-                                       'custom' => true,
-                               ),
-                       ),
-               );
-
-               $add_styles = array(
-                       'version' => WP_Theme_JSON::LATEST_SCHEMA,
-                       'styles'  => array(
-                               'blocks' => array(
-                                       'core/group' => array(
-                                               'spacing' => array(
-                                                       'padding' => array(
-                                                               'top' => '12px',
-                                                       ),
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
-
-               $add_key_in_styles = array(
-                       'version' => WP_Theme_JSON::LATEST_SCHEMA,
-                       'styles'  => array(
-                               'blocks' => array(
-                                       'core/group' => array(
-                                               'spacing' => array(
-                                                       'padding' => array(
-                                                               'bottom' => '12px',
-                                                       ),
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
-
-               $add_invalid_context = array(
-                       'version' => WP_Theme_JSON::LATEST_SCHEMA,
-                       'styles'  => array(
-                               'blocks' => array(
-                                       'core/para' => array(
-                                               'typography' => array(
-                                                       'lineHeight' => '12',
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
-
-               $update_presets = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'color'      => array(
-                                       'palette'   => array(
-                                               array(
-                                                       'slug'  => 'blue',
-                                                       'color' => 'blue',
-                                               ),
-                                       ),
-                                       'gradients' => array(
-                                               array(
-                                                       'slug'     => 'gradient',
-                                                       'gradient' => 'gradient',
-                                               ),
-                                       ),
-                               ),
-                               'typography' => array(
-                                       'fontSizes'    => array(
-                                               array(
-                                                       'slug' => 'fontSize',
-                                                       'size' => 'fontSize',
-                                               ),
-                                       ),
-                                       'fontFamilies' => array(
-                                               array(
-                                                       'slug'       => 'fontFamily',
-                                                       'fontFamily' => 'fontFamily',
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
-
-               $expected = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'color'      => array(
-                                       'custom'         => true,
-                                       'customGradient' => true,
-                                       'palette'        => array(
-                                               array(
-                                                       'slug'  => 'blue',
-                                                       'color' => 'blue',
-                                               ),
-                                       ),
-                                       'gradients'      => array(
-                                               array(
-                                                       'slug'     => 'gradient',
-                                                       'gradient' => 'gradient',
-                                               ),
-                                       ),
-                               ),
-                               'typography' => array(
-                                       'fontSizes' => array(
-                                               array(
-                                                       'slug' => 'fontSize',
-                                                       'size' => 'fontSize',
-                                               ),
-                                       ),
-                               ),
-                               'blocks'     => array(
-                                       'core/paragraph' => array(
-                                               'color' => array(
-                                                       'custom' => false,
-                                               ),
-                                       ),
-                                       'core/list'      => array(
-                                               'color' => array(
-                                                       'custom' => false,
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
-
-               $theme_json = new WP_Theme_JSON( $initial );
-               $theme_json->merge( new WP_Theme_JSON( $add_new_block ) );
-               $theme_json->merge( new WP_Theme_JSON( $add_key_in_settings ) );
-               $theme_json->merge( new WP_Theme_JSON( $update_key_in_settings ) );
-               $theme_json->merge( new WP_Theme_JSON( $add_styles ) );
-               $theme_json->merge( new WP_Theme_JSON( $add_key_in_styles ) );
-               $theme_json->merge( new WP_Theme_JSON( $add_invalid_context ) );
-               $theme_json->merge( new WP_Theme_JSON( $update_presets ) );
-               $actual = $theme_json->get_raw_data();
-
-               $this->assertEqualSetsWithIndex( $expected, $actual );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_get_from_editor_settings() {
-               $input = array(
-                       'disableCustomColors'    => true,
-                       'disableCustomGradients' => true,
-                       'disableCustomFontSizes' => true,
-                       'enableCustomLineHeight' => true,
-                       'enableCustomUnits'      => true,
-                       'colors'                 => array(
-                               array(
-                                       'slug'  => 'color-slug',
-                                       'name'  => 'Color Name',
-                                       'color' => 'colorvalue',
-                               ),
-                       ),
-                       'gradients'              => array(
-                               array(
-                                       'slug'     => 'gradient-slug',
-                                       'name'     => 'Gradient Name',
-                                       'gradient' => 'gradientvalue',
-                               ),
-                       ),
-                       'fontSizes'              => array(
-                               array(
-                                       'slug' => 'size-slug',
-                                       'name' => 'Size Name',
-                                       'size' => 'sizevalue',
-                               ),
-                       ),
-               );
-
-               $expected = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'color'      => array(
-                                       'custom'         => false,
-                                       'customGradient' => false,
-                                       'gradients'      => array(
-                                               array(
-                                                       'slug'     => 'gradient-slug',
-                                                       'name'     => 'Gradient Name',
-                                                       'gradient' => 'gradientvalue',
-                                               ),
-                                       ),
-                                       'palette'        => array(
-                                               array(
-                                                       'slug'  => 'color-slug',
-                                                       'name'  => 'Color Name',
-                                                       'color' => 'colorvalue',
-                                               ),
-                                       ),
-                               ),
-                               'spacing'    => array(
-                                       'units' => array( 'px', 'em', 'rem', 'vh', 'vw' ),
-                               ),
-                               'typography' => array(
-                                       'customFontSize'   => false,
-                                       'customLineHeight' => true,
-                                       'fontSizes'        => array(
-                                               array(
-                                                       'slug' => 'size-slug',
-                                                       'name' => 'Size Name',
-                                                       'size' => 'sizevalue',
-                                               ),
-                                       ),
-                               ),
-                       ),
-               );
-
-               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
-
-               $this->assertEqualSetsWithIndex( $expected, $actual );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_get_editor_settings_no_theme_support() {
-               $input = array(
-                       '__unstableEnableFullSiteEditingBlocks' => false,
-                       'disableCustomColors'                   => false,
-                       'disableCustomFontSizes'                => false,
-                       'disableCustomGradients'                => false,
-                       'enableCustomLineHeight'                => false,
-                       'enableCustomUnits'                     => false,
-                       'imageSizes'                            => array(
-                               array(
-                                       'slug' => 'thumbnail',
-                                       'name' => 'Thumbnail',
-                               ),
-                               array(
-                                       'slug' => 'medium',
-                                       'name' => 'Medium',
-                               ),
-                               array(
-                                       'slug' => 'large',
-                                       'name' => 'Large',
-                               ),
-                               array(
-                                       'slug' => 'full',
-                                       'name' => 'Full Size',
-                               ),
-                       ),
-                       'isRTL'                                 => false,
-                       'maxUploadFileSize'                     => 123,
-               );
-
-               $expected = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(
-                               'color'      => array(
-                                       'custom'         => true,
-                                       'customGradient' => true,
-                               ),
-                               'spacing'    => array(
-                                       'units' => false,
-                               ),
-                               'typography' => array(
-                                       'customFontSize'   => true,
-                                       'customLineHeight' => false,
-                               ),
-                       ),
-               );
-
-               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
-
-               $this->assertEqualSetsWithIndex( $expected, $actual );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_get_editor_settings_blank() {
-               $expected = array(
-                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
-                       'settings' => array(),
-               );
-               $actual   = WP_Theme_JSON::get_from_editor_settings( array() );
-
-               $this->assertEqualSetsWithIndex( $expected, $actual );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_get_editor_settings_custom_units_can_be_disabled() {
-               add_theme_support( 'custom-units', array() );
-               $input = get_default_block_editor_settings();
-
-               $expected = array(
-                       'units'         => array( array() ),
-                       'customPadding' => false,
-               );
-
-               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
-
-               $this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_get_editor_settings_custom_units_can_be_enabled() {
-               add_theme_support( 'custom-units' );
-               $input = get_default_block_editor_settings();
-
-               $expected = array(
-                       'units'         => array( 'px', 'em', 'rem', 'vh', 'vw' ),
-                       'customPadding' => false,
-               );
-
-               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
-
-               $this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       function test_get_editor_settings_custom_units_can_be_filtered() {
-               add_theme_support( 'custom-units', 'rem', 'em' );
-               $input = get_default_block_editor_settings();
-
-               $expected = array(
-                       'units'         => array( 'rem', 'em' ),
-                       'customPadding' => false,
-               );
-
-               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
-
-               $this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
-       }
-
-}
</del></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemephpfromrev50966trunktestsphpunitteststhemeWPThemephp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/theme/wpTheme.php (from rev 50966, trunk/tests/phpunit/tests/theme/WPTheme.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpTheme.php                               (rev 0)
+++ trunk/tests/phpunit/tests/theme/wpTheme.php 2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,247 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+/**
+ * Test WP_Theme class.
+ *
+ * @package WordPress
+ * @subpackage Theme
+ *
+ * @group themes
+ */
+class Tests_Theme_wpTheme extends WP_UnitTestCase {
+       function setUp() {
+               parent::setUp();
+               $this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
+
+               $this->orig_theme_dir            = $GLOBALS['wp_theme_directories'];
+               $GLOBALS['wp_theme_directories'] = array( $this->theme_root );
+
+               add_filter( 'theme_root', array( $this, '_theme_root' ) );
+               add_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
+               add_filter( 'template_root', array( $this, '_theme_root' ) );
+               // Clear caches.
+               wp_clean_themes_cache();
+               unset( $GLOBALS['wp_themes'] );
+       }
+
+       function tearDown() {
+               $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
+               wp_clean_themes_cache();
+               unset( $GLOBALS['wp_themes'] );
+               parent::tearDown();
+       }
+
+       // Replace the normal theme root directory with our premade test directory.
+       function _theme_root( $dir ) {
+               return $this->theme_root;
+       }
+       function test_new_WP_Theme_top_level() {
+               $theme = new WP_Theme( 'theme1', $this->theme_root );
+
+               // Meta.
+               $this->assertSame( 'My Theme', $theme->get( 'Name' ) );
+               $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) );
+               $this->assertSame( 'An example theme', $theme->get( 'Description' ) );
+               $this->assertSame( 'Minnie Bannister', $theme->get( 'Author' ) );
+               $this->assertSame( 'http://example.com/', $theme->get( 'AuthorURI' ) );
+               $this->assertSame( '1.3', $theme->get( 'Version' ) );
+               $this->assertSame( '', $theme->get( 'Template' ) );
+               $this->assertSame( 'publish', $theme->get( 'Status' ) );
+               $this->assertSame( array(), $theme->get( 'Tags' ) );
+
+               // Important.
+               $this->assertSame( 'theme1', $theme->get_stylesheet() );
+               $this->assertSame( 'theme1', $theme->get_template() );
+       }
+
+       function test_new_WP_Theme_subdir() {
+               $theme = new WP_Theme( 'subdir/theme2', $this->theme_root );
+
+               // Meta.
+               $this->assertSame( 'My Subdir Theme', $theme->get( 'Name' ) );
+               $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) );
+               $this->assertSame( 'An example theme in a sub directory', $theme->get( 'Description' ) );
+               $this->assertSame( 'Mr. WordPress', $theme->get( 'Author' ) );
+               $this->assertSame( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) );
+               $this->assertSame( '0.1', $theme->get( 'Version' ) );
+               $this->assertSame( '', $theme->get( 'Template' ) );
+               $this->assertSame( 'publish', $theme->get( 'Status' ) );
+               $this->assertSame( array(), $theme->get( 'Tags' ) );
+
+               // Important.
+               $this->assertSame( 'subdir/theme2', $theme->get_stylesheet() );
+               $this->assertSame( 'subdir/theme2', $theme->get_template() );
+       }
+
+       /**
+        * @ticket 20313
+        */
+       function test_new_WP_Theme_subdir_bad_root() {
+               // This is what get_theme_data() does when you pass it a style.css file for a theme in a subdirectory.
+               $theme = new WP_Theme( 'theme2', $this->theme_root . '/subdir' );
+
+               // Meta.
+               $this->assertSame( 'My Subdir Theme', $theme->get( 'Name' ) );
+               $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) );
+               $this->assertSame( 'An example theme in a sub directory', $theme->get( 'Description' ) );
+               $this->assertSame( 'Mr. WordPress', $theme->get( 'Author' ) );
+               $this->assertSame( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) );
+               $this->assertSame( '0.1', $theme->get( 'Version' ) );
+               $this->assertSame( '', $theme->get( 'Template' ) );
+               $this->assertSame( 'publish', $theme->get( 'Status' ) );
+               $this->assertSame( array(), $theme->get( 'Tags' ) );
+
+               // Important.
+               $this->assertSame( 'subdir/theme2', $theme->get_stylesheet() );
+               $this->assertSame( 'subdir/theme2', $theme->get_template() );
+       }
+
+       /**
+        * @ticket 21749
+        */
+       function test_wp_theme_uris_with_spaces() {
+               $theme = new WP_Theme( 'theme with spaces', $this->theme_root . '/subdir' );
+               // Make sure subdir/ is considered part of the stylesheet, as we must avoid encoding /'s.
+               $this->assertSame( 'subdir/theme with spaces', $theme->get_stylesheet() );
+
+               // Check that in a URI path, we have raw URL encoding (spaces become %20).
+               // Don't try to verify the complete URI path. get_theme_root_uri() breaks down quickly.
+               $this->assertSame( 'theme%20with%20spaces', basename( $theme->get_stylesheet_directory_uri() ) );
+               $this->assertSame( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) );
+
+               // Check that wp_customize_url() uses URL encoding, as it is a query arg (spaces become +).
+               $this->assertSame( admin_url( 'customize.php?theme=theme+with+spaces' ), wp_customize_url( 'theme with spaces' ) );
+       }
+
+       /**
+        * @ticket 21969
+        */
+       function test_theme_uris_with_spaces() {
+               $callback = array( $this, 'filter_theme_with_spaces' );
+               add_filter( 'stylesheet', $callback );
+               add_filter( 'template', $callback );
+
+               $this->assertSame( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_stylesheet_directory_uri() );
+               $this->assertSame( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_template_directory_uri() );
+
+               remove_filter( 'stylesheet', $callback );
+               remove_filter( 'template', $callback );
+       }
+
+       function filter_theme_with_spaces() {
+               return 'subdir/theme with spaces';
+       }
+
+       /**
+        * @ticket 26873
+        */
+       function test_display_method_on_get_method_failure() {
+               $theme = new WP_Theme( 'nonexistent', $this->theme_root );
+               $this->assertSame( 'nonexistent', $theme->get( 'Name' ) );
+               $this->assertFalse( $theme->get( 'AuthorURI' ) );
+               $this->assertFalse( $theme->get( 'Tags' ) );
+               $this->assertFalse( $theme->display( 'Tags' ) );
+       }
+
+       /**
+        * @ticket 40820
+        */
+       function test_child_theme_with_itself_as_parent_should_appear_as_broken() {
+               $theme  = new WP_Theme( 'child-parent-itself', $this->theme_root );
+               $errors = $theme->errors();
+               $this->assertWPError( $errors );
+               $this->assertSame( 'theme_child_invalid', $errors->get_error_code() );
+       }
+
+
+       /**
+        * Enable a single theme on a network.
+        *
+        * @ticket 30594
+        * @group ms-required
+        */
+       function test_wp_theme_network_enable_single_theme() {
+               $theme                  = 'testtheme-1';
+               $current_allowed_themes = get_site_option( 'allowedthemes' );
+               WP_Theme::network_enable_theme( $theme );
+               $new_allowed_themes = get_site_option( 'allowedthemes' );
+               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
+               $current_allowed_themes['testtheme-1'] = true; // Add the new theme to the previous set.
+
+               $this->assertSameSetsWithIndex( $current_allowed_themes, $new_allowed_themes );
+       }
+
+       /**
+        * Enable multiple themes on a network.
+        *
+        * @ticket 30594
+        * @group ms-required
+        */
+       function test_wp_theme_network_enable_multiple_themes() {
+               $themes                 = array( 'testtheme-2', 'testtheme-3' );
+               $current_allowed_themes = get_site_option( 'allowedthemes' );
+               WP_Theme::network_enable_theme( $themes );
+               $new_allowed_themes = get_site_option( 'allowedthemes' );
+               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
+               $current_allowed_themes = array_merge(
+                       $current_allowed_themes,
+                       array(
+                               'testtheme-2' => true,
+                               'testtheme-3' => true,
+                       )
+               );
+
+               $this->assertSameSetsWithIndex( $current_allowed_themes, $new_allowed_themes );
+       }
+
+       /**
+        * Disable a single theme on a network.
+        *
+        * @ticket 30594
+        * @group ms-required
+        */
+       function test_network_disable_single_theme() {
+               $current_allowed_themes = get_site_option( 'allowedthemes' );
+
+               $allowed_themes = array(
+                       'existing-1' => true,
+                       'existing-2' => true,
+                       'existing-3' => true,
+               );
+               update_site_option( 'allowedthemes', $allowed_themes );
+
+               $disable_theme = 'existing-2';
+               WP_Theme::network_disable_theme( $disable_theme );
+               $new_allowed_themes = get_site_option( 'allowedthemes' );
+               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
+               unset( $allowed_themes[ $disable_theme ] ); // Remove deleted theme from initial set.
+
+               $this->assertSameSetsWithIndex( $allowed_themes, $new_allowed_themes );
+       }
+
+       /**
+        * Disable multiple themes on a network.
+        *
+        * @ticket 30594
+        * @group ms-required
+        */
+       function test_network_disable_multiple_themes() {
+               $current_allowed_themes = get_site_option( 'allowedthemes' );
+
+               $allowed_themes = array(
+                       'existing-4' => true,
+                       'existing-5' => true,
+                       'existing-6' => true,
+               );
+               update_site_option( 'allowedthemes', $allowed_themes );
+
+               $disable_themes = array( 'existing-4', 'existing-5' );
+               WP_Theme::network_disable_theme( $disable_themes );
+               $new_allowed_themes = get_site_option( 'allowedthemes' );
+               update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value.
+               unset( $allowed_themes['existing-4'] );
+               unset( $allowed_themes['existing-5'] );
+
+               $this->assertSameSetsWithIndex( $allowed_themes, $new_allowed_themes );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeJsonphpfromrev50966trunktestsphpunitteststhemeclasswpthemejsonphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/theme/wpThemeJson.php (from rev 50966, trunk/tests/phpunit/tests/theme/class-wp-theme-json.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeJson.php                           (rev 0)
+++ trunk/tests/phpunit/tests/theme/wpThemeJson.php     2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,467 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * Test WP_Theme_JSON class.
+ *
+ * @package WordPress
+ * @subpackage Theme
+ * @since 5.8.0
+ *
+ * @group themes
+ */
+
+class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
+
+       /**
+        * @ticket 52991
+        */
+       function test_get_settings() {
+               $theme_json = new WP_Theme_JSON(
+                       array(
+                               'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                               'settings' => array(
+                                       'color'       => array(
+                                               'custom' => false,
+                                       ),
+                                       'invalid/key' => 'value',
+                                       'blocks'      => array(
+                                               'core/group' => array(
+                                                       'color'       => array(
+                                                               'custom' => false,
+                                                       ),
+                                                       'invalid/key' => 'value',
+                                               ),
+                                       ),
+                               ),
+                               'styles'   => array(
+                                       'color' => array(
+                                               'link' => 'blue',
+                                       ),
+                               ),
+                       )
+               );
+
+               $actual = $theme_json->get_settings();
+
+               $expected = array(
+                       'color'  => array(
+                               'custom' => false,
+                       ),
+                       'blocks' => array(
+                               'core/group' => array(
+                                       'color' => array(
+                                               'custom' => false,
+                                       ),
+                               ),
+                       ),
+               );
+
+               $this->assertEqualSetsWithIndex( $expected, $actual );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_merge_incoming_data() {
+               $initial = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'color'  => array(
+                                       'custom'  => false,
+                                       'palette' => array(
+                                               array(
+                                                       'slug'  => 'red',
+                                                       'color' => 'red',
+                                               ),
+                                               array(
+                                                       'slug'  => 'green',
+                                                       'color' => 'green',
+                                               ),
+                                       ),
+                               ),
+                               'blocks' => array(
+                                       'core/paragraph' => array(
+                                               'color' => array(
+                                                       'custom' => false,
+                                               ),
+                                       ),
+                               ),
+                       ),
+                       'styles'   => array(
+                               'typography' => array(
+                                       'fontSize' => '12',
+                               ),
+                       ),
+               );
+
+               $add_new_block = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'blocks' => array(
+                                       'core/list' => array(
+                                               'color' => array(
+                                                       'custom' => false,
+                                               ),
+                                       ),
+                               ),
+                       ),
+                       'styles'   => array(
+                               'blocks' => array(
+                                       'core/list' => array(
+                                               'typography' => array(
+                                                       'fontSize' => '12',
+                                               ),
+                                               'color'      => array(
+                                                       'background' => 'brown',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $add_key_in_settings = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'color' => array(
+                                       'customGradient' => true,
+                               ),
+                       ),
+               );
+
+               $update_key_in_settings = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'color' => array(
+                                       'custom' => true,
+                               ),
+                       ),
+               );
+
+               $add_styles = array(
+                       'version' => WP_Theme_JSON::LATEST_SCHEMA,
+                       'styles'  => array(
+                               'blocks' => array(
+                                       'core/group' => array(
+                                               'spacing' => array(
+                                                       'padding' => array(
+                                                               'top' => '12px',
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $add_key_in_styles = array(
+                       'version' => WP_Theme_JSON::LATEST_SCHEMA,
+                       'styles'  => array(
+                               'blocks' => array(
+                                       'core/group' => array(
+                                               'spacing' => array(
+                                                       'padding' => array(
+                                                               'bottom' => '12px',
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $add_invalid_context = array(
+                       'version' => WP_Theme_JSON::LATEST_SCHEMA,
+                       'styles'  => array(
+                               'blocks' => array(
+                                       'core/para' => array(
+                                               'typography' => array(
+                                                       'lineHeight' => '12',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $update_presets = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'color'      => array(
+                                       'palette'   => array(
+                                               array(
+                                                       'slug'  => 'blue',
+                                                       'color' => 'blue',
+                                               ),
+                                       ),
+                                       'gradients' => array(
+                                               array(
+                                                       'slug'     => 'gradient',
+                                                       'gradient' => 'gradient',
+                                               ),
+                                       ),
+                               ),
+                               'typography' => array(
+                                       'fontSizes'    => array(
+                                               array(
+                                                       'slug' => 'fontSize',
+                                                       'size' => 'fontSize',
+                                               ),
+                                       ),
+                                       'fontFamilies' => array(
+                                               array(
+                                                       'slug'       => 'fontFamily',
+                                                       'fontFamily' => 'fontFamily',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $expected = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'color'      => array(
+                                       'custom'         => true,
+                                       'customGradient' => true,
+                                       'palette'        => array(
+                                               array(
+                                                       'slug'  => 'blue',
+                                                       'color' => 'blue',
+                                               ),
+                                       ),
+                                       'gradients'      => array(
+                                               array(
+                                                       'slug'     => 'gradient',
+                                                       'gradient' => 'gradient',
+                                               ),
+                                       ),
+                               ),
+                               'typography' => array(
+                                       'fontSizes' => array(
+                                               array(
+                                                       'slug' => 'fontSize',
+                                                       'size' => 'fontSize',
+                                               ),
+                                       ),
+                               ),
+                               'blocks'     => array(
+                                       'core/paragraph' => array(
+                                               'color' => array(
+                                                       'custom' => false,
+                                               ),
+                                       ),
+                                       'core/list'      => array(
+                                               'color' => array(
+                                                       'custom' => false,
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $theme_json = new WP_Theme_JSON( $initial );
+               $theme_json->merge( new WP_Theme_JSON( $add_new_block ) );
+               $theme_json->merge( new WP_Theme_JSON( $add_key_in_settings ) );
+               $theme_json->merge( new WP_Theme_JSON( $update_key_in_settings ) );
+               $theme_json->merge( new WP_Theme_JSON( $add_styles ) );
+               $theme_json->merge( new WP_Theme_JSON( $add_key_in_styles ) );
+               $theme_json->merge( new WP_Theme_JSON( $add_invalid_context ) );
+               $theme_json->merge( new WP_Theme_JSON( $update_presets ) );
+               $actual = $theme_json->get_raw_data();
+
+               $this->assertEqualSetsWithIndex( $expected, $actual );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_get_from_editor_settings() {
+               $input = array(
+                       'disableCustomColors'    => true,
+                       'disableCustomGradients' => true,
+                       'disableCustomFontSizes' => true,
+                       'enableCustomLineHeight' => true,
+                       'enableCustomUnits'      => true,
+                       'colors'                 => array(
+                               array(
+                                       'slug'  => 'color-slug',
+                                       'name'  => 'Color Name',
+                                       'color' => 'colorvalue',
+                               ),
+                       ),
+                       'gradients'              => array(
+                               array(
+                                       'slug'     => 'gradient-slug',
+                                       'name'     => 'Gradient Name',
+                                       'gradient' => 'gradientvalue',
+                               ),
+                       ),
+                       'fontSizes'              => array(
+                               array(
+                                       'slug' => 'size-slug',
+                                       'name' => 'Size Name',
+                                       'size' => 'sizevalue',
+                               ),
+                       ),
+               );
+
+               $expected = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'color'      => array(
+                                       'custom'         => false,
+                                       'customGradient' => false,
+                                       'gradients'      => array(
+                                               array(
+                                                       'slug'     => 'gradient-slug',
+                                                       'name'     => 'Gradient Name',
+                                                       'gradient' => 'gradientvalue',
+                                               ),
+                                       ),
+                                       'palette'        => array(
+                                               array(
+                                                       'slug'  => 'color-slug',
+                                                       'name'  => 'Color Name',
+                                                       'color' => 'colorvalue',
+                                               ),
+                                       ),
+                               ),
+                               'spacing'    => array(
+                                       'units' => array( 'px', 'em', 'rem', 'vh', 'vw' ),
+                               ),
+                               'typography' => array(
+                                       'customFontSize'   => false,
+                                       'customLineHeight' => true,
+                                       'fontSizes'        => array(
+                                               array(
+                                                       'slug' => 'size-slug',
+                                                       'name' => 'Size Name',
+                                                       'size' => 'sizevalue',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
+
+               $this->assertEqualSetsWithIndex( $expected, $actual );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_get_editor_settings_no_theme_support() {
+               $input = array(
+                       '__unstableEnableFullSiteEditingBlocks' => false,
+                       'disableCustomColors'                   => false,
+                       'disableCustomFontSizes'                => false,
+                       'disableCustomGradients'                => false,
+                       'enableCustomLineHeight'                => false,
+                       'enableCustomUnits'                     => false,
+                       'imageSizes'                            => array(
+                               array(
+                                       'slug' => 'thumbnail',
+                                       'name' => 'Thumbnail',
+                               ),
+                               array(
+                                       'slug' => 'medium',
+                                       'name' => 'Medium',
+                               ),
+                               array(
+                                       'slug' => 'large',
+                                       'name' => 'Large',
+                               ),
+                               array(
+                                       'slug' => 'full',
+                                       'name' => 'Full Size',
+                               ),
+                       ),
+                       'isRTL'                                 => false,
+                       'maxUploadFileSize'                     => 123,
+               );
+
+               $expected = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(
+                               'color'      => array(
+                                       'custom'         => true,
+                                       'customGradient' => true,
+                               ),
+                               'spacing'    => array(
+                                       'units' => false,
+                               ),
+                               'typography' => array(
+                                       'customFontSize'   => true,
+                                       'customLineHeight' => false,
+                               ),
+                       ),
+               );
+
+               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
+
+               $this->assertEqualSetsWithIndex( $expected, $actual );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_get_editor_settings_blank() {
+               $expected = array(
+                       'version'  => WP_Theme_JSON::LATEST_SCHEMA,
+                       'settings' => array(),
+               );
+               $actual   = WP_Theme_JSON::get_from_editor_settings( array() );
+
+               $this->assertEqualSetsWithIndex( $expected, $actual );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_get_editor_settings_custom_units_can_be_disabled() {
+               add_theme_support( 'custom-units', array() );
+               $input = get_default_block_editor_settings();
+
+               $expected = array(
+                       'units'         => array( array() ),
+                       'customPadding' => false,
+               );
+
+               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
+
+               $this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_get_editor_settings_custom_units_can_be_enabled() {
+               add_theme_support( 'custom-units' );
+               $input = get_default_block_editor_settings();
+
+               $expected = array(
+                       'units'         => array( 'px', 'em', 'rem', 'vh', 'vw' ),
+                       'customPadding' => false,
+               );
+
+               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
+
+               $this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_get_editor_settings_custom_units_can_be_filtered() {
+               add_theme_support( 'custom-units', 'rem', 'em' );
+               $input = get_default_block_editor_settings();
+
+               $expected = array(
+                       'units'         => array( 'rem', 'em' ),
+                       'customPadding' => false,
+               );
+
+               $actual = WP_Theme_JSON::get_from_editor_settings( $input );
+
+               $this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
+       }
+
+}
</ins></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeJsonResolverphpfromrev50966trunktestsphpunitteststhemeclasswpthemejsonresolverphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php (from rev 50966, trunk/tests/phpunit/tests/theme/class-wp-theme-json-resolver.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php                           (rev 0)
+++ trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php     2021-05-24 13:24:05 UTC (rev 50967)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,159 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * Test WP_Theme_JSON_Resolver class.
+ *
+ * @package WordPress
+ * @subpackage Theme
+ * @since 5.8.0
+ *
+ * @group themes
+ */
+class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
+
+       function setUp() {
+               parent::setUp();
+               $this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
+
+               $this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
+
+               // /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
+               $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
+
+               add_filter( 'theme_root', array( $this, 'filter_set_theme_root' ) );
+               add_filter( 'stylesheet_root', array( $this, 'filter_set_theme_root' ) );
+               add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) );
+               // Clear caches.
+               wp_clean_themes_cache();
+               unset( $GLOBALS['wp_themes'] );
+       }
+
+       function tearDown() {
+               $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
+               wp_clean_themes_cache();
+               unset( $GLOBALS['wp_themes'] );
+               parent::tearDown();
+       }
+
+       function filter_set_theme_root() {
+               return $this->theme_root;
+       }
+
+       function filter_set_locale_to_polish() {
+               return 'pl_PL';
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_fields_are_extracted() {
+               $actual = WP_Theme_JSON_Resolver::get_fields_to_translate();
+
+               $expected = array(
+                       array(
+                               'path'    => array( 'settings', 'typography', 'fontSizes' ),
+                               'key'     => 'name',
+                               'context' => 'Font size name',
+                       ),
+                       array(
+                               'path'    => array( 'settings', 'color', 'palette' ),
+                               'key'     => 'name',
+                               'context' => 'Color name',
+                       ),
+                       array(
+                               'path'    => array( 'settings', 'color', 'gradients' ),
+                               'key'     => 'name',
+                               'context' => 'Gradient name',
+                       ),
+                       array(
+                               'path'    => array( 'settings', 'color', 'duotone' ),
+                               'key'     => 'name',
+                               'context' => 'Duotone name',
+                       ),
+                       array(
+                               'path'    => array( 'settings', 'blocks', '*', 'typography', 'fontSizes' ),
+                               'key'     => 'name',
+                               'context' => 'Font size name',
+                       ),
+                       array(
+                               'path'    => array( 'settings', 'blocks', '*', 'color', 'palette' ),
+                               'key'     => 'name',
+                               'context' => 'Color name',
+                       ),
+                       array(
+                               'path'    => array( 'settings', 'blocks', '*', 'color', 'gradients' ),
+                               'key'     => 'name',
+                               'context' => 'Gradient name',
+                       ),
+               );
+
+               $this->assertEquals( $expected, $actual );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_translations_are_applied() {
+               add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
+               load_textdomain( 'fse', realpath( DIR_TESTDATA . '/languages/themes/fse-pl_PL.mo' ) );
+
+               switch_theme( 'fse' );
+
+               $actual = WP_Theme_JSON_Resolver::get_theme_data();
+
+               unload_textdomain( 'fse' );
+               remove_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
+
+               $this->assertSame( wp_get_theme()->get( 'TextDomain' ), 'fse' );
+               $this->assertSame(
+                       array(
+                               'color'  => array(
+                                       'palette' => array(
+                                               array(
+                                                       'slug'  => 'light',
+                                                       'name'  => 'Jasny',
+                                                       'color' => '#f5f7f9',
+                                               ),
+                                               array(
+                                                       'slug'  => 'dark',
+                                                       'name'  => 'Ciemny',
+                                                       'color' => '#000',
+                                               ),
+                                       ),
+                                       'custom'  => false,
+                               ),
+                               'blocks' => array(
+                                       'core/paragraph' => array(
+                                               'color' => array(
+                                                       'palette' => array(
+                                                               array(
+                                                                       'slug'  => 'light',
+                                                                       'name'  => 'Jasny',
+                                                                       'color' => '#f5f7f9',
+                                                               ),
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                       ),
+                       $actual->get_settings()
+               );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       function test_switching_themes_recalculates_data() {
+               // By default, the theme for unit tests is "default",
+               // which doesn't have theme.json support.
+               $default = WP_Theme_JSON_Resolver::theme_has_support();
+
+               // Switch to a theme that does have support.
+               switch_theme( 'fse' );
+               $fse = WP_Theme_JSON_Resolver::theme_has_support();
+
+               $this->assertSame( false, $default );
+               $this->assertSame( true, $fse );
+       }
+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>