<!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>[55673] trunk: Editor: Add selectors field to block type definition</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/55673">55673</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/55673","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>gziolo</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-04-21 10:41:58 +0000 (Fri, 21 Apr 2023)</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'>Editor: Add selectors field to block type definition
Adds support for the new selectors property for block types. It adds it to the allowed metadata when registering a block type, makes the WP_Block_Type class aware of it, exposes it through the block types REST API, and the get_block_editor_server_block_settings function.
Corresponding work in the Gutenberg plugin: https://github.com/WordPress/gutenberg/pull/46496.
Fixes <a href="https://core.trac.wordpress.org/ticket/57585">#57585</a>.
Props aaronrobertshaw, hellofromTonya.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludespostphp">trunk/src/wp-admin/includes/post.php</a></li>
<li><a href="#trunksrcwpincludesblocksphp">trunk/src/wp-includes/blocks.php</a></li>
<li><a href="#trunksrcwpincludesclasswpblocktypephp">trunk/src/wp-includes/class-wp-block-type.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestblocktypescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php</a></li>
<li><a href="#trunktestsphpunitdatablocksnoticeblockjson">trunk/tests/phpunit/data/blocks/notice/block.json</a></li>
<li><a href="#trunktestsphpunittestsadminincludesPostphp">trunk/tests/phpunit/tests/admin/includesPost.php</a></li>
<li><a href="#trunktestsphpunittestsblocksregisterphp">trunk/tests/phpunit/tests/blocks/register.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestblocktypecontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludespostphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/post.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/post.php 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/src/wp-admin/includes/post.php 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2178,6 +2178,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * of a block relevant for client registration.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0 Added `selectors` field.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array An associative array of registered block data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2192,6 +2193,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'attributes' => 'attributes',
</span><span class="cx" style="display: block; padding: 0 10px"> 'provides_context' => 'providesContext',
</span><span class="cx" style="display: block; padding: 0 10px"> 'uses_context' => 'usesContext',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors' => 'selectors',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'supports' => 'supports',
</span><span class="cx" style="display: block; padding: 0 10px"> 'category' => 'category',
</span><span class="cx" style="display: block; padding: 0 10px"> 'styles' => 'styles',
</span></span></pre></div>
<a id="trunksrcwpincludesblocksphp"></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/blocks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/blocks.php 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/src/wp-includes/blocks.php 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -300,6 +300,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.7.0 Added support for `textdomain` field and i18n handling for all translatable fields.
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0 Added support for `variations` and `viewScript` fields.
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0 Added support for `render` field.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0 Added `selectors` field.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file_or_folder Path to the JSON file with metadata definition for
</span><span class="cx" style="display: block; padding: 0 10px"> * the block or path to the folder where the `block.json` file is located.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -382,6 +383,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'attributes' => 'attributes',
</span><span class="cx" style="display: block; padding: 0 10px"> 'providesContext' => 'provides_context',
</span><span class="cx" style="display: block; padding: 0 10px"> 'usesContext' => 'uses_context',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors' => 'selectors',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'supports' => 'supports',
</span><span class="cx" style="display: block; padding: 0 10px"> 'styles' => 'styles',
</span><span class="cx" style="display: block; padding: 0 10px"> 'variations' => 'variations',
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpblocktypephp"></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-block-type.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-block-type.php 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/src/wp-includes/class-wp-block-type.php 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,6 +118,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $variations = array();
</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">+ * Custom CSS selectors for theme.json style generation.
+ *
+ * @since 6.3.0
+ * @var array
+ */
+ public $selectors = array();
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Supported features.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -245,6 +253,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0 Added the `editor_script_handles`, `script_handles`, `view_script_handles,
</span><span class="cx" style="display: block; padding: 0 10px"> * `editor_style_handles`, and `style_handles` properties.
</span><span class="cx" style="display: block; padding: 0 10px"> * Deprecated the `editor_script`, `script`, `view_script`, `editor_style`, and `style` properties.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0 Added the `selectors` property.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see register_block_type()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -268,6 +277,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @type string|null $textdomain The translation textdomain.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type array[] $styles Alternative block styles.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type array[] $variations Block variations.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type array $selectors Custom CSS selectors for theme.json style generation.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @type array|null $supports Supported features.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type array|null $example Structured data for the block preview.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type callable|null $render_callback Block type render callback.
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestblocktypescontrollerphp"></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-block-types-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-block-types-controller.php 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -237,6 +237,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0 Renamed `$block_type` to `$item` to match parent class for PHP 8 named parameter support.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0 Added `selectors` field.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param WP_Block_Type $item Block type data.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Full details about the request.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -278,6 +279,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'ancestor',
</span><span class="cx" style="display: block; padding: 0 10px"> 'provides_context',
</span><span class="cx" style="display: block; padding: 0 10px"> 'uses_context',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'supports',
</span><span class="cx" style="display: block; padding: 0 10px"> 'styles',
</span><span class="cx" style="display: block; padding: 0 10px"> 'textdomain',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -379,6 +381,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieves the block type' schema, conforming to JSON Schema.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0 Added `selectors` field.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -518,6 +521,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors' => array(
+ 'description' => __( 'Custom CSS selectors.' ),
+ 'type' => 'object',
+ 'default' => array(),
+ 'properties' => array(),
+ 'context' => array( 'embed', 'view', 'edit' ),
+ 'readonly' => true,
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'supports' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Block supports.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span></span></pre></div>
<a id="trunktestsphpunitdatablocksnoticeblockjson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/blocks/notice/block.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/blocks/notice/block.json 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/tests/phpunit/data/blocks/notice/block.json 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,6 +27,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "type": "string"
</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">+ "selectors": {
+ "root": ".wp-block-notice"
+ },
</ins><span class="cx" style="display: block; padding: 0 10px"> "supports": {
</span><span class="cx" style="display: block; padding: 0 10px"> "align": true,
</span><span class="cx" style="display: block; padding: 0 10px"> "lightBlockWrapper": true
</span></span></pre></div>
<a id="trunktestsphpunittestsadminincludesPostphp"></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/admin/includesPost.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/admin/includesPost.php 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/tests/phpunit/tests/admin/includesPost.php 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -826,6 +826,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'category' => 'common',
</span><span class="cx" style="display: block; padding: 0 10px"> 'render_callback' => 'foo',
</span><span class="cx" style="display: block; padding: 0 10px"> 'ancestor' => array( 'core/test-ancestor' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors' => array( 'root' => '.wp-block-test' ),
</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"> register_block_type( $name, $settings );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -845,6 +846,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'lock' => array( 'type' => 'object' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'usesContext' => array(),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors' => array( 'root' => '.wp-block-test' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'category' => 'common',
</span><span class="cx" style="display: block; padding: 0 10px"> 'styles' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'ancestor' => array( 'core/test-ancestor' ),
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksregisterphp"></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/blocks/register.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/register.php 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/tests/phpunit/tests/blocks/register.php 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -483,6 +483,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50263
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50328
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 57585
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_block_registers_with_metadata_fixture() {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = register_block_type_from_metadata(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -515,7 +516,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $result->provides_context
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( 'groupId' ), $result->uses_context );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // @ticket 57585
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'root' => '.wp-block-notice' ),
+ $result->selectors,
+ 'Block type should contain selectors from metadata.'
+ );
+ $this->assertSame(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'align' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'lightBlockWrapper' => true,
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestblocktypecontrollerphp"></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-block-type-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-block-type-controller.php 2023-04-21 09:48:41 UTC (rev 55672)
+++ trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php 2023-04-21 10:41:58 UTC (rev 55673)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -196,6 +196,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47620
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 57585
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_invalid() {
</span><span class="cx" style="display: block; padding: 0 10px"> $block_type = 'fake/invalid';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -216,6 +217,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'example' => 'invalid_example',
</span><span class="cx" style="display: block; padding: 0 10px"> 'parent' => 'invalid_parent',
</span><span class="cx" style="display: block; padding: 0 10px"> 'ancestor' => 'invalid_ancestor',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors' => 'invalid_selectors',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'supports' => 'invalid_supports',
</span><span class="cx" style="display: block; padding: 0 10px"> 'styles' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'render_callback' => 'invalid_callback',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -247,6 +249,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( 'invalid_keywords' ), $data['keywords'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( 'invalid_parent' ), $data['parent'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( 'invalid_ancestor' ), $data['ancestor'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array(), $data['selectors'], 'invalid selectors defaults to empty array' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['supports'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['styles'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $data['example'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -265,6 +268,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47620
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 57585
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_defaults() {
</span><span class="cx" style="display: block; padding: 0 10px"> $block_type = 'fake/false';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,6 +288,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'keywords' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'parent' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'ancestor' => false,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'selectors' => false,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'supports' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'styles' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'render_callback' => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -316,6 +321,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['keywords'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['parent'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['ancestor'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array(), $data['selectors'], 'selectors defaults to empty array' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['supports'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['styles'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $data['example'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -534,6 +540,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47620
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 57585
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_schema() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$admin_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -541,7 +548,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</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->assertCount( 28, $properties );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertCount( 29, $properties );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'api_version', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'title', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'icon', $properties );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -551,6 +558,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'textdomain', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'name', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'attributes', $properties );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertArrayHasKey( 'selectors', $properties, 'schema must contain selectors' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'supports', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'category', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'is_dynamic', $properties );
</span></span></pre>
</div>
</div>
</body>
</html>