<!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>[47921] trunk: REST API: Add additional fields to the themes controller.</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/47921">47921</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/47921","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>TimothyBlynJacobs</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-06-07 06:44:08 +0000 (Sun, 07 Jun 2020)</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'>REST API: Add additional fields to the themes controller.
When the themes controller was introduced it only returned a theme's supported features. This adds the majority of a theme's header information to the response.
Props ockham, spacedmonkey.
Fixes <a href="https://core.trac.wordpress.org/ticket/49906">#49906</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestthemescontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php</a></li>
<li><a href="#trunktestsphpunitteststhemethemeDirphp">trunk/tests/phpunit/tests/theme/themeDir.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/tests/phpunit/data/themedir1/rest-api/</li>
<li><a href="#trunktestsphpunitdatathemedir1restapistylecss">trunk/tests/phpunit/data/themedir1/rest-api/style.css</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp"></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/rest-api/endpoints/class-wp-rest-themes-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2020-06-07 01:27:39 UTC (rev 47920)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2020-06-07 06:44:08 UTC (rev 47921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -115,10 +115,65 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( in_array( 'theme_supports', $fields, true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( rest_is_field_included( 'stylesheet', $fields ) ) {
+ $data['stylesheet'] = $theme->get_stylesheet();
+ }
+
+ if ( rest_is_field_included( 'template', $fields ) ) {
+ /**
+ * Use the get_template() method, not the 'Template' header, for finding the template.
+ * The 'Template' header is only good for what was written in the style.css, while
+ * get_template() takes into account where WordPress actually located the theme and
+ * whether it is actually valid.
+ */
+ $data['template'] = $theme->get_template();
+ }
+
+ $plain_field_mappings = array(
+ 'requires_php' => 'RequiresPHP',
+ 'requires_wp' => 'RequiresWP',
+ 'textdomain' => 'TextDomain',
+ 'version' => 'Version',
+ );
+
+ foreach ( $plain_field_mappings as $field => $header ) {
+ if ( rest_is_field_included( $field, $fields ) ) {
+ $data[ $field ] = $theme->get( $header );
+ }
+ }
+
+ if ( rest_is_field_included( 'screenshot', $fields ) ) {
+ // Using $theme->get_screenshot() with no args to get absolute URL.
+ $data['screenshot'] = $theme->get_screenshot() ?: '';
+ }
+
+ $rich_field_mappings = array(
+ 'author' => 'Author',
+ 'author_uri' => 'AuthorURI',
+ 'description' => 'Description',
+ 'name' => 'Name',
+ 'tags' => 'Tags',
+ 'theme_uri' => 'ThemeURI',
+ );
+
+ foreach ( $rich_field_mappings as $field => $header ) {
+ if ( rest_is_field_included( "{$field}.raw", $fields ) ) {
+ $data[ $field ]['raw'] = $theme->display( $header, false, true );
+ }
+
+ if ( rest_is_field_included( "{$field}.rendered", $fields ) ) {
+ $data[ $field ]['rendered'] = $theme->display( $header );
+ }
+ }
+
+ if ( rest_is_field_included( 'theme_supports', $fields ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $item_schemas = $this->get_item_schema();
</span><span class="cx" style="display: block; padding: 0 10px"> $theme_supports = $item_schemas['properties']['theme_supports']['properties'];
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $theme_supports as $name => $schema ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! rest_is_field_included( "theme_supports.{$name}", $fields ) ) {
+ continue;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'formats' === $name ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,6 +247,117 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'theme',
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span><span class="cx" style="display: block; padding: 0 10px"> 'properties' => array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'stylesheet' => array(
+ 'description' => __( 'The theme\'s stylesheet. This uniquely identifies the theme.' ),
+ 'type' => 'string',
+ 'readonly' => true,
+ ),
+ 'template' => array(
+ 'description' => __( 'The theme\'s template. If this is a child theme, this refers to the parent theme, otherwise this is the same as the theme\'s stylesheet.' ),
+ 'type' => 'string',
+ 'readonly' => true,
+ ),
+ 'author' => array(
+ 'description' => __( 'The theme author.' ),
+ 'type' => 'object',
+ 'readonly' => true,
+ 'properties' => array(
+ 'raw' => array(
+ 'description' => __( 'The theme author\'s name, as found in the theme header.' ),
+ 'type' => 'string',
+ ),
+ 'rendered' => array(
+ 'description' => __( 'HTML for the theme author, transformed for display.' ),
+ 'type' => 'string',
+ ),
+ ),
+ ),
+ 'author_uri' => array(
+ 'description' => __( 'The website of the theme author.' ),
+ 'type' => 'object',
+ 'readonly' => true,
+ 'properties' => array(
+ 'raw' => array(
+ 'description' => __( 'The website of the theme author, as found in the theme header.' ),
+ 'type' => 'string',
+ 'format' => 'uri',
+ ),
+ 'rendered' => array(
+ 'description' => __( 'The website of the theme author, transformed for display.' ),
+ 'type' => 'string',
+ 'format' => 'uri',
+ ),
+ ),
+ ),
+ 'description' => array(
+ 'description' => __( 'A description of the theme.' ),
+ 'type' => 'object',
+ 'readonly' => true,
+ 'properties' => array(
+ 'raw' => array(
+ 'description' => __( 'The theme description, as found in the theme header.' ),
+ 'type' => 'string',
+ ),
+ 'rendered' => array(
+ 'description' => __( 'The theme description, transformed for display.' ),
+ 'type' => 'string',
+ ),
+ ),
+ ),
+ 'name' => array(
+ 'description' => __( 'The name of the theme.' ),
+ 'type' => 'object',
+ 'readonly' => true,
+ 'properties' => array(
+ 'raw' => array(
+ 'description' => __( 'The theme name, as found in the theme header.' ),
+ 'type' => 'string',
+ ),
+ 'rendered' => array(
+ 'description' => __( 'The theme name, transformed for display.' ),
+ 'type' => 'string',
+ ),
+ ),
+ ),
+ 'requires_php' => array(
+ 'description' => __( 'The minimum PHP version required for the theme to work.' ),
+ 'type' => 'string',
+ 'readonly' => true,
+ ),
+ 'requires_wp' => array(
+ 'description' => __( 'The minimum WordPress version required for the theme to work.' ),
+ 'type' => 'string',
+ 'readonly' => true,
+ ),
+ 'screenshot' => array(
+ 'description' => __( 'The theme\'s screenshot URL.' ),
+ 'type' => 'string',
+ 'format' => 'uri',
+ 'readonly' => true,
+ ),
+ 'tags' => array(
+ 'description' => __( 'Tags indicating styles and features of the theme.' ),
+ 'type' => 'object',
+ 'readonly' => true,
+ 'properties' => array(
+ 'raw' => array(
+ 'description' => __( 'The theme tags, as found in the theme header.' ),
+ 'type' => 'array',
+ 'items' => array(
+ 'type' => 'string',
+ ),
+ ),
+ 'rendered' => array(
+ 'description' => __( 'The theme tags, transformed for display.' ),
+ 'type' => 'string',
+ ),
+ ),
+ ),
+ 'textdomain' => array(
+ 'description' => __( 'The theme\'s textdomain.' ),
+ 'type' => 'string',
+ 'readonly' => true,
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'theme_supports' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Features supported by this theme.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -458,6 +624,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'theme_uri' => array(
+ 'description' => __( 'The URI of the theme\'s webpage.' ),
+ 'type' => 'object',
+ 'readonly' => true,
+ 'properties' => array(
+ 'raw' => array(
+ 'description' => __( 'The URI of the theme\'s webpage, as found in the theme header.' ),
+ 'type' => 'string',
+ 'format' => 'uri',
+ ),
+ 'rendered' => array(
+ 'description' => __( 'The URI of the theme\'s webpage, transformed for display.' ),
+ 'type' => 'string',
+ 'format' => 'uri',
+ ),
+ ),
+ ),
+ 'version' => array(
+ 'description' => __( 'The theme\'s current version.' ),
+ 'type' => 'string',
+ 'readonly' => true,
+ ),
</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="trunktestsphpunitdatathemedir1restapistylecss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/themedir1/rest-api/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/themedir1/rest-api/style.css (rev 0)
+++ trunk/tests/phpunit/data/themedir1/rest-api/style.css 2020-06-07 06:44:08 UTC (rev 47921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,15 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+Theme Name: REST Theme
+Theme URI: http://wordpress.org/?search=1&term=2
+Description: The 9' foot tall theme.
+Version: 1.6
+Author: Michael Heilemann
+Author URI: http://binarybonsai.com/?search=1&term=2
+Tags: holiday, custom-menu
+Template: default
+Requires at least: 5.3
+Requires PHP: 5.6
+Text Domain: rest-api
+*/
+
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/themedir1/rest-api/style.css
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestsrestapirestthemescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php 2020-06-07 01:27:39 UTC (rev 47920)
+++ trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php 2020-06-07 06:44:08 UTC (rev 47921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -125,6 +125,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::setUp();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$contributor_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_theme( 'rest-api' );
</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="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,7 +151,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_get_theme_response( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author',
+ 'author_uri',
+ 'description',
+ 'name',
+ 'requires_php',
+ 'requires_wp',
+ 'screenshot',
+ 'stylesheet',
+ 'tags',
+ 'template',
+ 'textdomain',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'theme_supports',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'theme_uri',
+ 'version',
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualSets( $fields, array_keys( $data[0] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,8 +221,44 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = self::perform_active_theme_request( 'OPTIONS' );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $properties = $data['schema']['properties'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( 1, count( $properties ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( 14, count( $properties ) );
+
+ $this->assertArrayHasKey( 'author', $properties );
+ $this->assertArrayHasKey( 'raw', $properties['author']['properties'] );
+ $this->assertArrayHasKey( 'rendered', $properties['author']['properties'] );
+
+ $this->assertArrayHasKey( 'author_uri', $properties );
+ $this->assertArrayHasKey( 'raw', $properties['author_uri']['properties'] );
+ $this->assertArrayHasKey( 'rendered', $properties['author_uri']['properties'] );
+
+ $this->assertArrayHasKey( 'description', $properties );
+ $this->assertArrayHasKey( 'raw', $properties['description']['properties'] );
+ $this->assertArrayHasKey( 'rendered', $properties['description']['properties'] );
+
+ $this->assertArrayHasKey( 'name', $properties );
+ $this->assertArrayHasKey( 'raw', $properties['name']['properties'] );
+ $this->assertArrayHasKey( 'rendered', $properties['name']['properties'] );
+
+ $this->assertArrayHasKey( 'requires_php', $properties );
+ $this->assertArrayHasKey( 'requires_wp', $properties );
+ $this->assertArrayHasKey( 'screenshot', $properties );
+ $this->assertArrayHasKey( 'stylesheet', $properties );
+
+ $this->assertArrayHasKey( 'tags', $properties );
+ $this->assertArrayHasKey( 'raw', $properties['tags']['properties'] );
+ $this->assertArrayHasKey( 'items', $properties['tags']['properties']['raw'] );
+ $this->assertArrayHasKey( 'rendered', $properties['tags']['properties'] );
+
+ $this->assertArrayHasKey( 'template', $properties );
+ $this->assertArrayHasKey( 'textdomain', $properties );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'theme_supports', $properties );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $this->assertArrayHasKey( 'theme_uri', $properties );
+ $this->assertArrayHasKey( 'raw', $properties['theme_uri']['properties'] );
+ $this->assertArrayHasKey( 'rendered', $properties['theme_uri']['properties'] );
+
+ $this->assertArrayHasKey( 'version', $properties );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $theme_supports = $properties['theme_supports']['properties'];
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 20, count( $theme_supports ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'align-wide', $theme_supports );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -234,6 +284,148 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 49906
+ */
+ public function test_theme_author() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'author', $result[0] );
+ $this->assertSame( 'Michael Heilemann', $result[0]['author']['raw'] );
+ $this->assertSame(
+ '<a href="http://binarybonsai.com/?search=1&term=2">Michael Heilemann</a>',
+ $result[0]['author']['rendered']
+ );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_author_uri() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'author_uri', $result[0] );
+ $this->assertSame( 'http://binarybonsai.com/?search=1&term=2', $result[0]['author_uri']['raw'] );
+ $this->assertSame( 'http://binarybonsai.com/?search=1&term=2', $result[0]['author_uri']['rendered'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_description() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'description', $result[0] );
+ $this->assertSame(
+ 'The 9\' foot tall theme.',
+ $result[0]['description']['raw']
+ );
+ $this->assertSame(
+ 'The 9′ foot tall theme.',
+ $result[0]['description']['rendered']
+ );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_requires_php() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'requires_php', $result[0] );
+ $this->assertSame( '5.6', $result[0]['requires_php'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_requires_wp() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'requires_wp', $result[0] );
+ $this->assertSame( '5.3', $result[0]['requires_wp'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_name() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'name', $result[0] );
+ $this->assertSame( 'REST Theme', $result[0]['name']['raw'] );
+ $this->assertSame( 'REST Theme', $result[0]['name']['rendered'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_screenshot() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'screenshot', $result[0] );
+ $this->assertSame( '', $result[0]['screenshot'] ); // No screenshot for default theme
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_stylesheet() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'stylesheet', $result[0] );
+ $this->assertSame( 'rest-api', $result[0]['stylesheet'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_tags() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'tags', $result[0] );
+ $this->assertSame( array( 'holiday', 'custom-menu' ), $result[0]['tags']['raw'] );
+ $this->assertSame( 'holiday, custom-menu', $result[0]['tags']['rendered'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_template() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'template', $result[0] );
+ $this->assertSame( 'default', $result[0]['template'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_textdomain() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'textdomain', $result[0] );
+ $this->assertSame( 'rest-api', $result[0]['textdomain'] );
+ }
+
+ public function test_theme_theme_uri() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_uri', $result[0] );
+ $this->assertSame( 'http://wordpress.org/?search=1&term=2', $result[0]['theme_uri']['raw'] );
+ $this->assertSame( 'http://wordpress.org/?search=1&term=2', $result[0]['theme_uri']['rendered'] );
+ }
+
+ /**
+ * @ticket 49906
+ */
+ public function test_theme_version() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'version', $result[0] );
+ $this->assertSame( '1.6', $result[0]['version'] );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 49037
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_theme_supports_disable_custom_colors_false() {
</span></span></pre></div>
<a id="trunktestsphpunitteststhemethemeDirphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/themeDir.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/themeDir.php 2020-06-07 01:27:39 UTC (rev 47920)
+++ trunk/tests/phpunit/tests/theme/themeDir.php 2020-06-07 06:44:08 UTC (rev 47921)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,6 +163,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'Theme with Spaces in the Directory',
</span><span class="cx" style="display: block; padding: 0 10px"> 'Internationalized Theme',
</span><span class="cx" style="display: block; padding: 0 10px"> 'camelCase',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'REST Theme',
</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"> sort( $theme_names );
</span></span></pre>
</div>
</div>
</body>
</html>