<!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>[51491] trunk/tests/phpunit/tests/blocks: Tests: Rename classes in `phpunit/tests/blocks/` per the naming conventions.</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/51491">51491</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/51491","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-07-26 18:45:48 +0000 (Mon, 26 Jul 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'>Tests: Rename classes in `phpunit/tests/blocks/` per the naming conventions.

https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to <a href="https://core.trac.wordpress.org/changeset/47780">[47780]</a>, <a href="https://core.trac.wordpress.org/changeset/48911">[48911]</a>, <a href="https://core.trac.wordpress.org/changeset/49327">[49327]</a>, <a href="https://core.trac.wordpress.org/changeset/50291">[50291]</a>, <a href="https://core.trac.wordpress.org/changeset/50292">[50292]</a>, <a href="https://core.trac.wordpress.org/changeset/50342">[50342]</a>, <a href="https://core.trac.wordpress.org/changeset/50452">[50452]</a>, <a href="https://core.trac.wordpress.org/changeset/50453">[50453]</a>, <a href="https://core.trac.wordpress.org/changeset/50456">[50456]</a>, <a href="https://core.trac.wordpress.org/changeset/50967">[50967]</a>, <a href="https://core.trac.wordpress.org/changeset/50968">[50968]</a>, <a href="https://core.trac.wordpress.org/changeset/50969">[50969]</a>.

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsblocksregisterphp">trunk/tests/phpunit/tests/blocks/register.php</a></li>
<li><a href="#trunktestsphpunittestsblocksrenderphp">trunk/tests/phpunit/tests/blocks/render.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsblockscontextphp">trunk/tests/phpunit/tests/blocks/context.php</a></li>
<li><a href="#trunktestsphpunittestsblockseditorphp">trunk/tests/phpunit/tests/blocks/editor.php</a></li>
<li><a href="#trunktestsphpunittestsblocksrenderReusablephp">trunk/tests/phpunit/tests/blocks/renderReusable.php</a></li>
<li><a href="#trunktestsphpunittestsblocksserializephp">trunk/tests/phpunit/tests/blocks/serialize.php</a></li>
<li><a href="#trunktestsphpunittestsblockssupportedStylesphp">trunk/tests/phpunit/tests/blocks/supportedStyles.php</a></li>
<li><a href="#trunktestsphpunittestsblockswpBlockphp">trunk/tests/phpunit/tests/blocks/wpBlock.php</a></li>
<li><a href="#trunktestsphpunittestsblockswpBlockListphp">trunk/tests/phpunit/tests/blocks/wpBlockList.php</a></li>
<li><a href="#trunktestsphpunittestsblockswpBlockParserphp">trunk/tests/phpunit/tests/blocks/wpBlockParser.php</a></li>
<li><a href="#trunktestsphpunittestsblockswpBlockTypephp">trunk/tests/phpunit/tests/blocks/wpBlockType.php</a></li>
<li><a href="#trunktestsphpunittestsblockswpBlockTypeRegistryphp">trunk/tests/phpunit/tests/blocks/wpBlockTypeRegistry.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsblocksblockcontextphp">trunk/tests/phpunit/tests/blocks/block-context.php</a></li>
<li><a href="#trunktestsphpunittestsblocksblockeditorphp">trunk/tests/phpunit/tests/blocks/block-editor.php</a></li>
<li><a href="#trunktestsphpunittestsblocksblocklistphp">trunk/tests/phpunit/tests/blocks/block-list.php</a></li>
<li><a href="#trunktestsphpunittestsblocksblockparserphp">trunk/tests/phpunit/tests/blocks/block-parser.php</a></li>
<li><a href="#trunktestsphpunittestsblocksblocksupportedstylesphp">trunk/tests/phpunit/tests/blocks/block-supported-styles.php</a></li>
<li><a href="#trunktestsphpunittestsblocksblocktyperegistryphp">trunk/tests/phpunit/tests/blocks/block-type-registry.php</a></li>
<li><a href="#trunktestsphpunittestsblocksblocktypephp">trunk/tests/phpunit/tests/blocks/block-type.php</a></li>
<li><a href="#trunktestsphpunittestsblocksblockphp">trunk/tests/phpunit/tests/blocks/block.php</a></li>
<li><a href="#trunktestsphpunittestsblocksrenderreusablephp">trunk/tests/phpunit/tests/blocks/render-reusable.php</a></li>
<li><a href="#trunktestsphpunittestsblocksserializationphp">trunk/tests/phpunit/tests/blocks/serialization.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsblocksblockcontextphp"></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/blocks/block-context.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block-context.php        2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block-context.php  2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,215 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * WP_Block_Context Tests
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.5.0
- */
-
-/**
- * Tests for WP_Block_Context
- *
- * @since 5.5.0
- *
- * @group blocks
- */
-class WP_Block_Context_Test extends WP_UnitTestCase {
-
-       /**
-        * Registered block names.
-        *
-        * @var string[]
-        */
-       private $registered_block_names = array();
-
-       /**
-        * Sets up each test method.
-        */
-       public function setUp() {
-               global $post;
-
-               parent::setUp();
-
-               $args = array(
-                       'post_content' => 'example',
-                       'post_excerpt' => '',
-               );
-
-               $post = $this->factory()->post->create_and_get( $args );
-               setup_postdata( $post );
-       }
-
-       /**
-        * Tear down each test method.
-        */
-       public function tearDown() {
-               while ( ! empty( $this->registered_block_names ) ) {
-                       $block_name = array_pop( $this->registered_block_names );
-                       unregister_block_type( $block_name );
-               }
-
-               parent::tearDown();
-       }
-
-       /**
-        * Registers a block type.
-        *
-        * @param string|WP_Block_Type $name Block type name including namespace, or alternatively a
-        *                                   complete WP_Block_Type instance. In case a WP_Block_Type
-        *                                   is provided, the $args parameter will be ignored.
-        * @param array                $args {
-        *     Optional. Array of block type arguments. Any arguments may be defined, however the
-        *     ones described below are supported by default. Default empty array.
-        *
-        *     @type callable $render_callback Callback used to render blocks of this block type.
-        * }
-        */
-       protected function register_block_type( $name, $args ) {
-               register_block_type( $name, $args );
-
-               $this->registered_block_names[] = $name;
-       }
-
-       /**
-        * Tests that a block which provides context makes that context available to
-        * its inner blocks.
-        *
-        * @ticket 49927
-        */
-       function test_provides_block_context() {
-               $provided_context = array();
-
-               $this->register_block_type(
-                       'gutenberg/test-context-provider',
-                       array(
-                               'attributes'       => array(
-                                       'contextWithAssigned'   => array(
-                                               'type' => 'number',
-                                       ),
-                                       'contextWithDefault'    => array(
-                                               'type'    => 'number',
-                                               'default' => 0,
-                                       ),
-                                       'contextWithoutDefault' => array(
-                                               'type' => 'number',
-                                       ),
-                                       'contextNotRequested'   => array(
-                                               'type' => 'number',
-                                       ),
-                               ),
-                               'provides_context' => array(
-                                       'gutenberg/contextWithAssigned'   => 'contextWithAssigned',
-                                       'gutenberg/contextWithDefault'    => 'contextWithDefault',
-                                       'gutenberg/contextWithoutDefault' => 'contextWithoutDefault',
-                                       'gutenberg/contextNotRequested'   => 'contextNotRequested',
-                               ),
-                       )
-               );
-
-               $this->register_block_type(
-                       'gutenberg/test-context-consumer',
-                       array(
-                               'uses_context'    => array(
-                                       'gutenberg/contextWithDefault',
-                                       'gutenberg/contextWithAssigned',
-                                       'gutenberg/contextWithoutDefault',
-                               ),
-                               'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
-                                       $provided_context[] = $block->context;
-
-                                       return '';
-                               },
-                       )
-               );
-
-               $parsed_blocks = parse_blocks(
-                       '<!-- wp:gutenberg/test-context-provider {"contextWithAssigned":10} -->' .
-                       '<!-- wp:gutenberg/test-context-consumer /-->' .
-                       '<!-- /wp:gutenberg/test-context-provider -->'
-               );
-
-               render_block( $parsed_blocks[0] );
-
-               $this->assertSame(
-                       array(
-                               'gutenberg/contextWithDefault'  => 0,
-                               'gutenberg/contextWithAssigned' => 10,
-                       ),
-                       $provided_context[0]
-               );
-       }
-
-       /**
-        * Tests that a block can receive default-provided context through
-        * render_block.
-        *
-        * @ticket 49927
-        */
-       function test_provides_default_context() {
-               global $post;
-
-               $provided_context = array();
-
-               $this->register_block_type(
-                       'gutenberg/test-context-consumer',
-                       array(
-                               'uses_context'    => array( 'postId', 'postType' ),
-                               'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
-                                       $provided_context[] = $block->context;
-
-                                       return '';
-                               },
-                       )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:gutenberg/test-context-consumer /-->' );
-
-               render_block( $parsed_blocks[0] );
-
-               $this->assertSame(
-                       array(
-                               'postId'   => $post->ID,
-                               'postType' => $post->post_type,
-                       ),
-                       $provided_context[0]
-               );
-       }
-
-       /**
-        * Tests that default block context can be filtered.
-        *
-        * @ticket 49927
-        */
-       function test_default_context_is_filterable() {
-               $provided_context = array();
-
-               $this->register_block_type(
-                       'gutenberg/test-context-consumer',
-                       array(
-                               'uses_context'    => array( 'example' ),
-                               'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
-                                       $provided_context[] = $block->context;
-
-                                       return '';
-                               },
-                       )
-               );
-
-               $filter_block_context = function( $context ) {
-                       $context['example'] = 'ok';
-                       return $context;
-               };
-
-               $parsed_blocks = parse_blocks( '<!-- wp:gutenberg/test-context-consumer /-->' );
-
-               add_filter( 'render_block_context', $filter_block_context );
-
-               render_block( $parsed_blocks[0] );
-
-               remove_filter( 'render_block_context', $filter_block_context );
-
-               $this->assertSame( array( 'example' => 'ok' ), $provided_context[0] );
-       }
-
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksblockeditorphp"></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/blocks/block-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block-editor.php 2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block-editor.php   2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,511 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * WP_Block Tests
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.5.0
- */
-
-/**
- * Tests for the block editor methods.
- *
- * @since 5.5.0
- *
- * @group blocks
- */
-class WP_Test_Block_Editor extends WP_UnitTestCase {
-
-       /**
-        * Sets up each test method.
-        */
-       public function setUp() {
-               global $post;
-
-               parent::setUp();
-
-               $args = array(
-                       'post_title' => 'Example',
-               );
-
-               $post = $this->factory()->post->create_and_get( $args );
-
-               global $wp_rest_server;
-               $wp_rest_server = new Spy_REST_Server;
-               do_action( 'rest_api_init', $wp_rest_server );
-       }
-
-       public function tearDown() {
-               /** @var WP_REST_Server $wp_rest_server */
-               global $wp_rest_server;
-               $wp_rest_server = null;
-               parent::tearDown();
-       }
-
-       function filter_set_block_categories_post( $block_categories, $post ) {
-               if ( empty( $post ) ) {
-                       return $block_categories;
-               }
-
-               return array(
-                       array(
-                               'slug'  => 'filtered-category',
-                               'title' => 'Filtered Category',
-                               'icon'  => null,
-                       ),
-               );
-       }
-
-       function filter_set_allowed_block_types_post( $allowed_block_types, $post ) {
-               if ( empty( $post ) ) {
-                       return $allowed_block_types;
-               }
-
-               return array( 'test/filtered-block' );
-       }
-
-       function filter_set_block_editor_settings_post( $editor_settings, $post ) {
-               if ( empty( $post ) ) {
-                       return $allowed_block_types;
-               }
-
-               return array(
-                       'filter' => 'deprecated',
-               );
-       }
-
-       /**
-        * @ticket 52920
-        */
-       function test_block_editor_context_no_settings() {
-               $context = new WP_Block_Editor_Context();
-
-               $this->assertNull( $context->post );
-       }
-
-       /**
-        * @ticket 52920
-        */
-       function test_block_editor_context_post() {
-               $context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
-
-               $this->assertSame( get_post(), $context->post );
-       }
-
-       /**
-        * @ticket 52920
-        * @expectedDeprecated block_categories
-        */
-       function test_get_block_categories_deprecated_filter_post_object() {
-               add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 );
-
-               $block_categories = get_block_categories( get_post() );
-
-               remove_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ) );
-
-               $this->assertSameSets(
-                       array(
-                               array(
-                                       'slug'  => 'filtered-category',
-                                       'title' => 'Filtered Category',
-                                       'icon'  => null,
-                               ),
-                       ),
-                       $block_categories
-               );
-       }
-
-       /**
-        * @ticket 52920
-        * @expectedDeprecated block_categories
-        */
-       function test_get_block_categories_deprecated_filter_post_editor() {
-               add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 );
-
-               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
-               $block_categories    = get_block_categories( $post_editor_context );
-
-               remove_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ) );
-
-               $this->assertSameSets(
-                       array(
-                               array(
-                                       'slug'  => 'filtered-category',
-                                       'title' => 'Filtered Category',
-                                       'icon'  => null,
-                               ),
-                       ),
-                       $block_categories
-               );
-       }
-
-       /**
-        * @ticket 52920
-        */
-       function test_get_allowed_block_types_default() {
-               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
-               $allowed_block_types = get_allowed_block_types( $post_editor_context );
-
-               $this->assertTrue( $allowed_block_types );
-       }
-
-       /**
-        * @ticket 52920
-        * @expectedDeprecated allowed_block_types
-        */
-       function test_get_allowed_block_types_deprecated_filter_post_editor() {
-               add_filter( 'allowed_block_types', array( $this, 'filter_set_allowed_block_types_post' ), 10, 2 );
-
-               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
-               $allowed_block_types = get_allowed_block_types( $post_editor_context );
-
-               remove_filter( 'allowed_block_types', array( $this, 'filter_set_allowed_block_types_post' ) );
-
-               $this->assertSameSets( array( 'test/filtered-block' ), $allowed_block_types );
-       }
-
-       /**
-        * @ticket 52920
-        */
-       function test_get_default_block_editor_settings() {
-               $settings = get_default_block_editor_settings();
-
-               $this->assertCount( 16, $settings );
-               $this->assertFalse( $settings['alignWide'] );
-               $this->assertIsArray( $settings['allowedMimeTypes'] );
-               $this->assertTrue( $settings['allowedBlockTypes'] );
-               $this->assertSameSets(
-                       array(
-                               array(
-                                       'slug'  => 'text',
-                                       'title' => 'Text',
-                                       'icon'  => null,
-                               ),
-                               array(
-                                       'slug'  => 'media',
-                                       'title' => 'Media',
-                                       'icon'  => null,
-                               ),
-                               array(
-                                       'slug'  => 'design',
-                                       'title' => 'Design',
-                                       'icon'  => null,
-                               ),
-                               array(
-                                       'slug'  => 'widgets',
-                                       'title' => 'Widgets',
-                                       'icon'  => null,
-                               ),
-                               array(
-                                       'slug'  => 'theme',
-                                       'title' => 'Theme',
-                                       'icon'  => null,
-                               ),
-                               array(
-                                       'slug'  => 'embed',
-                                       'title' => 'Embeds',
-                                       'icon'  => null,
-                               ),
-                               array(
-                                       'slug'  => 'reusable',
-                                       'title' => 'Reusable Blocks',
-                                       'icon'  => null,
-                               ),
-                       ),
-                       $settings['blockCategories']
-               );
-               $this->assertFalse( $settings['disableCustomColors'] );
-               $this->assertFalse( $settings['disableCustomFontSizes'] );
-               $this->assertFalse( $settings['disableCustomGradients'] );
-               $this->assertFalse( $settings['enableCustomLineHeight'] );
-               $this->assertFalse( $settings['enableCustomSpacing'] );
-               $this->assertFalse( $settings['enableCustomUnits'] );
-               $this->assertFalse( $settings['isRTL'] );
-               $this->assertSame( 'large', $settings['imageDefaultSize'] );
-               $this->assertSameSets(
-                       array(
-                               array(
-                                       'width'  => 150,
-                                       'height' => 150,
-                                       'crop'   => true,
-                               ),
-                               array(
-                                       'width'  => 300,
-                                       'height' => 300,
-                                       'crop'   => false,
-                               ),
-                               array(
-                                       'width'  => 1024,
-                                       'height' => 1024,
-                                       'crop'   => false,
-                               ),
-                       ),
-                       $settings['imageDimensions']
-               );
-               $this->assertTrue( $settings['imageEditing'] );
-               $this->assertSameSets(
-                       array(
-                               array(
-                                       'slug' => 'full',
-                                       'name' => 'Full Size',
-                               ),
-                               array(
-                                       'slug' => 'large',
-                                       'name' => 'Large',
-                               ),
-                               array(
-                                       'slug' => 'medium',
-                                       'name' => 'Medium',
-                               ),
-                               array(
-                                       'slug' => 'thumbnail',
-                                       'name' => 'Thumbnail',
-                               ),
-                       ),
-                       $settings['imageSizes']
-               );
-               $this->assertIsInt( $settings['maxUploadFileSize'] );
-       }
-
-       /**
-        * @ticket 53397
-        */
-       function test_get_legacy_widget_block_editor_settings() {
-               $settings = get_legacy_widget_block_editor_settings();
-               $this->assertCount( 1, $settings );
-               $this->assertSameSets(
-                       array(
-                               'archives',
-                               'block',
-                               'calendar',
-                               'categories',
-                               'custom_html',
-                               'media_audio',
-                               'media_gallery',
-                               'media_image',
-                               'media_video',
-                               'pages',
-                               'recent-comments',
-                               'recent-posts',
-                               'rss',
-                               'search',
-                               'tag_cloud',
-                               'text',
-                       ),
-                       $settings['widgetTypesToHideFromLegacyWidgetBlock']
-               );
-       }
-
-       /**
-        * @ticket 52920
-        */
-       function test_get_block_editor_settings_overrides_default_settings_all_editors() {
-               function filter_allowed_block_types_my_editor() {
-                       return array( 'test/filtered-my-block' );
-               }
-               function filter_block_categories_my_editor() {
-                       return array(
-                               array(
-                                       'slug'  => 'filtered-my-category',
-                                       'title' => 'Filtered My Category',
-                                       'icon'  => null,
-                               ),
-                       );
-               }
-               function filter_block_editor_settings_my_editor( $editor_settings ) {
-                       $editor_settings['maxUploadFileSize'] = 12345;
-
-                       return $editor_settings;
-               }
-
-               add_filter( 'allowed_block_types_all', 'filter_allowed_block_types_my_editor', 10, 1 );
-               add_filter( 'block_categories_all', 'filter_block_categories_my_editor', 10, 1 );
-               add_filter( 'block_editor_settings_all', 'filter_block_editor_settings_my_editor', 10, 1 );
-
-               $my_editor_context = new WP_Block_Editor_Context();
-               $settings          = get_block_editor_settings( array(), $my_editor_context );
-
-               remove_filter( 'allowed_block_types_all', 'filter_allowed_block_types_my_editor' );
-               remove_filter( 'block_categories_all', 'filter_block_categories_my_editor' );
-               remove_filter( 'block_editor_settings_all', 'filter_block_editor_settings_my_editor' );
-
-               $this->assertSameSets( array( 'test/filtered-my-block' ), $settings['allowedBlockTypes'] );
-               $this->assertSameSets(
-                       array(
-                               array(
-                                       'slug'  => 'filtered-my-category',
-                                       'title' => 'Filtered My Category',
-                                       'icon'  => null,
-                               ),
-                       ),
-                       $settings['blockCategories']
-               );
-               $this->assertSame( 12345, $settings['maxUploadFileSize'] );
-       }
-
-       /**
-        * @ticket 53458
-        */
-       function test_get_block_editor_settings_theme_json_settings() {
-               switch_theme( 'block-theme' );
-
-               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
-
-               $settings = get_block_editor_settings( array(), $post_editor_context );
-
-               // Related entry in theme.json: settings.color.palette
-               $this->assertSameSetsWithIndex(
-                       array(
-                               array(
-                                       'slug'  => 'light',
-                                       'name'  => 'Light',
-                                       'color' => '#f5f7f9',
-                               ),
-                               array(
-                                       'slug'  => 'dark',
-                                       'name'  => 'Dark',
-                                       'color' => '#000',
-                               ),
-                       ),
-                       $settings['colors']
-               );
-               // settings.color.gradients
-               $this->assertSameSetsWithIndex(
-                       array(
-                               array(
-                                       'name'     => 'Custom gradient',
-                                       'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)',
-                                       'slug'     => 'custom-gradient',
-                               ),
-                       ),
-                       $settings['gradients']
-               );
-               // settings.typography.fontSizes
-               $this->assertSameSetsWithIndex(
-                       array(
-                               array(
-                                       'name' => 'Custom',
-                                       'slug' => 'custom',
-                                       'size' => '100px',
-                               ),
-                       ),
-                       $settings['fontSizes']
-               );
-               // settings.color.custom
-               $this->assertTrue( $settings['disableCustomColors'] );
-               // settings.color.customGradient
-               $this->assertTrue( $settings['disableCustomGradients'] );
-               // settings.typography.customFontSize
-               $this->assertTrue( $settings['disableCustomFontSizes'] );
-               // settings.typography.customLineHeight
-               $this->assertTrue( $settings['enableCustomLineHeight'] );
-               // settings.spacing.enableCustomUnits
-               $this->assertSameSets( array( 'rem' ), $settings['enableCustomUnits'] );
-               // settings.spacing.customPadding
-               $this->assertTrue( $settings['enableCustomSpacing'] );
-
-               switch_theme( WP_DEFAULT_THEME );
-       }
-
-       /**
-        * @ticket 52920
-        * @expectedDeprecated block_editor_settings
-        */
-       function test_get_block_editor_settings_deprecated_filter_post_editor() {
-               add_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ), 10, 2 );
-
-               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
-               $settings            = get_block_editor_settings( array(), $post_editor_context );
-
-               remove_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ) );
-
-               $this->assertSameSets(
-                       array(
-                               'filter' => 'deprecated',
-                       ),
-                       $settings
-               );
-       }
-
-       /**
-        * @ticket 52920
-        */
-       function test_block_editor_rest_api_preload_no_paths() {
-               $editor_context = new WP_Block_Editor_Context();
-               block_editor_rest_api_preload( array(), $editor_context );
-
-               $after = implode( '', wp_scripts()->registered['wp-api-fetch']->extra['after'] );
-               $this->assertStringNotContainsString( 'wp.apiFetch.createPreloadingMiddleware', $after );
-       }
-
-       /**
-        * @ticket 52920
-        * @expectedDeprecated block_editor_preload_paths
-        */
-       function test_block_editor_rest_api_preload_deprecated_filter_post_editor() {
-               function filter_remove_preload_paths( $preload_paths, $post ) {
-                       if ( empty( $post ) ) {
-                               return $preload_paths;
-                       }
-                       return array();
-               }
-               add_filter( 'block_editor_preload_paths', 'filter_remove_preload_paths', 10, 2 );
-
-               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
-               block_editor_rest_api_preload(
-                       array(
-                               array( '/wp/v2/blocks', 'OPTIONS' ),
-                       ),
-                       $post_editor_context
-               );
-
-               remove_filter( 'block_editor_preload_paths', 'filter_remove_preload_paths' );
-
-               $after = implode( '', wp_scripts()->registered['wp-api-fetch']->extra['after'] );
-               $this->assertStringNotContainsString( 'wp.apiFetch.createPreloadingMiddleware', $after );
-       }
-
-       /**
-        * @ticket 52920
-        */
-       function test_block_editor_rest_api_preload_filter_all() {
-               function filter_add_preload_paths( $preload_paths, WP_Block_Editor_Context $context ) {
-                       if ( empty( $context->post ) ) {
-                               array_push( $preload_paths, array( '/wp/v2/types', 'OPTIONS' ) );
-                       }
-
-                       return $preload_paths;
-               }
-               add_filter( 'block_editor_rest_api_preload_paths', 'filter_add_preload_paths', 10, 2 );
-
-               $editor_context = new WP_Block_Editor_Context();
-               block_editor_rest_api_preload(
-                       array(
-                               array( '/wp/v2/blocks', 'OPTIONS' ),
-                       ),
-                       $editor_context
-               );
-
-               remove_filter( 'block_editor_rest_api_preload_paths', 'filter_add_preload_paths' );
-
-               $after = implode( '', wp_scripts()->registered['wp-api-fetch']->extra['after'] );
-               $this->assertStringContainsString( 'wp.apiFetch.createPreloadingMiddleware', $after );
-               $this->assertStringContainsString( '"\/wp\/v2\/blocks"', $after );
-               $this->assertStringContainsString( '"\/wp\/v2\/types"', $after );
-       }
-
-       /**
-        * @ticket 53344
-        */
-       function test_get_block_editor_theme_styles() {
-               $theme_styles = get_block_editor_theme_styles();
-               $this->assertCount( 1, $theme_styles );
-               $this->assertSameSets(
-                       array(
-                               'css'            => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }',
-                               '__unstableType' => 'core',
-                       ),
-                       $theme_styles[0]
-               );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksblocklistphp"></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/blocks/block-list.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block-list.php   2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block-list.php     2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,112 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * WP_Block_List tests.
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.5.0
- */
-
-/**
- * Tests for WP_Block_List
- *
- * @since 5.5.0
- *
- * @group blocks
- */
-class WP_Block_List_Test extends WP_UnitTestCase {
-
-       /**
-        * Fake block type registry.
-        *
-        * @var WP_Block_Type_Registry
-        */
-       private $registry = null;
-
-       /**
-        * Set up each test method.
-        */
-       public function setUp() {
-               parent::setUp();
-
-               $this->registry = new WP_Block_Type_Registry();
-               $this->registry->register( 'core/example', array() );
-       }
-
-       /**
-        * Tear down each test method.
-        */
-       public function tearDown() {
-               $this->registry = null;
-
-               parent::tearDown();
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_array_access() {
-               $parsed_blocks = parse_blocks( '<!-- wp:example /-->' );
-               $context       = array();
-               $blocks        = new WP_Block_List( $parsed_blocks, $context, $this->registry );
-
-               // Test "offsetExists".
-               $this->assertArrayHasKey( 0, $blocks );
-
-               // Test "offsetGet".
-               $this->assertSame( 'core/example', $blocks[0]->name );
-
-               // Test "offsetSet".
-               $parsed_blocks[0]['blockName'] = 'core/updated';
-               $blocks[0]                     = new WP_Block( $parsed_blocks[0], $context, $this->registry );
-               $this->assertSame( 'core/updated', $blocks[0]->name );
-
-               // Test "offsetUnset".
-               unset( $blocks[0] );
-               $this->assertArrayNotHasKey( 0, $blocks );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_iterable() {
-               $parsed_blocks = parse_blocks( '<!-- wp:example --><!-- wp:example /--><!-- /wp:example -->' );
-               $context       = array();
-               $blocks        = new WP_Block_List( $parsed_blocks, $context, $this->registry );
-               $assertions    = 0;
-
-               foreach ( $blocks as $block ) {
-                       $this->assertSame( 'core/example', $block->name );
-                       $assertions++;
-                       foreach ( $block->inner_blocks as $inner_block ) {
-                               $this->assertSame( 'core/example', $inner_block->name );
-                               $assertions++;
-                       }
-               }
-
-               $blocks->rewind();
-               while ( $blocks->valid() ) {
-                       $key   = $blocks->key();
-                       $block = $blocks->current();
-                       $this->assertSame( 0, $key );
-                       $assertions++;
-                       $this->assertSame( 'core/example', $block->name );
-                       $assertions++;
-                       $blocks->next();
-               }
-
-               $this->assertSame( 4, $assertions );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_countable() {
-               $parsed_blocks = parse_blocks( '<!-- wp:example /-->' );
-               $context       = array();
-               $blocks        = new WP_Block_List( $parsed_blocks, $context, $this->registry );
-
-               $this->assertCount( 1, $blocks );
-       }
-
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksblockparserphp"></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/blocks/block-parser.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block-parser.php 2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block-parser.php   2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,119 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * WP_Block_Parser tests.
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.0.0
- */
-
-/**
- * Tests for WP_Block_Parser
- *
- * @since 5.0.0
- *
- * @group blocks
- */
-class WP_Test_Block_Parser extends WP_UnitTestCase {
-       /**
-        * The location of the fixtures to test with.
-        *
-        * @since 5.0.0
-        * @var string
-        */
-       protected static $fixtures_dir;
-
-       /**
-        * @ticket 45109
-        */
-       public function data_parsing_test_filenames() {
-               self::$fixtures_dir = DIR_TESTDATA . '/blocks/fixtures';
-
-               $fixture_filenames = array_merge(
-                       glob( self::$fixtures_dir . '/*.json' ),
-                       glob( self::$fixtures_dir . '/*.html' )
-               );
-
-               $fixture_filenames = array_values(
-                       array_unique(
-                               array_map(
-                                       array( $this, 'clean_fixture_filename' ),
-                                       $fixture_filenames
-                               )
-                       )
-               );
-
-               return array_map(
-                       array( $this, 'pass_parser_fixture_filenames' ),
-                       $fixture_filenames
-               );
-       }
-
-       /**
-        * @dataProvider data_parsing_test_filenames
-        * @ticket 45109
-        */
-       public function test_default_parser_output( $html_filename, $parsed_json_filename ) {
-               $html_path        = self::$fixtures_dir . '/' . $html_filename;
-               $parsed_json_path = self::$fixtures_dir . '/' . $parsed_json_filename;
-
-               foreach ( array( $html_path, $parsed_json_path ) as $filename ) {
-                       if ( ! file_exists( $filename ) ) {
-                               throw new Exception( "Missing fixture file: '$filename'" );
-                       }
-               }
-
-               $html            = self::strip_r( file_get_contents( $html_path ) );
-               $expected_parsed = json_decode( self::strip_r( file_get_contents( $parsed_json_path ) ), true );
-
-               $parser = new WP_Block_Parser();
-               $result = json_decode( json_encode( $parser->parse( $html ) ), true );
-
-               $this->assertSame(
-                       $expected_parsed,
-                       $result,
-                       "File '$parsed_json_filename' does not match expected value"
-               );
-       }
-
-       /**
-        * Helper function to remove relative paths and extension from a filename, leaving just the fixture name.
-        *
-        * @since 5.0.0
-        *
-        * @param string $filename The filename to clean.
-        * @return string The cleaned fixture name.
-        */
-       protected function clean_fixture_filename( $filename ) {
-               $filename = wp_basename( $filename );
-               $filename = preg_replace( '/\..+$/', '', $filename );
-               return $filename;
-       }
-
-       /**
-        * Helper function to return the filenames needed to test the parser output.
-        *
-        * @since 5.0.0
-        *
-        * @param string $filename The cleaned fixture name.
-        * @return array The input and expected output filenames for that fixture.
-        */
-       protected function pass_parser_fixture_filenames( $filename ) {
-               return array(
-                       "$filename.html",
-                       "$filename.parsed.json",
-               );
-       }
-
-       /**
-        * Helper function to remove '\r' characters from a string.
-        *
-        * @since 5.0.0
-        *
-        * @param string $input The string to remove '\r' from.
-        * @return string The input string, with '\r' characters removed.
-        */
-       protected function strip_r( $input ) {
-               return str_replace( "\r", '', $input );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksblocksupportedstylesphp"></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/blocks/block-supported-styles.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block-supported-styles.php       2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block-supported-styles.php 2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,729 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * Block Tests
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.6.0
- */
-
-/**
- * Test block supported styles.
- *
- * @since 5.6.0
- *
- * @group blocks
- */
-class Block_Supported_Styles_Test extends WP_UnitTestCase {
-
-       /**
-        * Block content to test with (i.e. what's wrapped by the block wrapper `<div />`).
-        *
-        * @var string
-        */
-       const BLOCK_CONTENT = '
-               <p data-image-description="&lt;p&gt;Test!&lt;/p&gt;">Test</p>
-               <p>äöü</p>
-               <p>ß</p>
-               <p>系の家庭に</p>
-               <p>Example &lt;p&gt;Test!&lt;/p&gt;</p>
-       ';
-
-       /**
-        * Registered block names.
-        *
-        * @var string[]
-        */
-       private $registered_block_names = array();
-
-       /**
-        * Tear down each test method.
-        */
-       public function tearDown() {
-               while ( ! empty( $this->registered_block_names ) ) {
-                       $block_name = array_pop( $this->registered_block_names );
-                       unregister_block_type( $block_name );
-               }
-
-               parent::tearDown();
-       }
-
-       /**
-        * Registers a block type.
-        *
-        * @param string|WP_Block_Type $name Block type name including namespace, or alternatively a
-        *                                   complete WP_Block_Type instance. In case a WP_Block_Type
-        *                                   is provided, the $args parameter will be ignored.
-        * @param array                $args {
-        *     Optional. Array of block type arguments. Any arguments may be defined, however the
-        *     ones described below are supported by default. Default empty array.
-        *
-        *     @type callable $render_callback Callback used to render blocks of this block type.
-        * }
-        */
-       protected function register_block_type( $name, $args ) {
-               register_block_type( $name, $args );
-
-               $this->registered_block_names[] = $name;
-       }
-
-       /**
-        * Retrieves attribute such as 'class' or 'style' from the rendered block string.
-        *
-        * @param string $attribute Name of attribute to get.
-        * @param string $block String of rendered block to check.
-        */
-       private function get_attribute_from_block( $attribute, $block ) {
-               $start_index = strpos( $block, $attribute . '="' ) + strlen( $attribute ) + 2;
-               $split_arr   = substr( $block, $start_index );
-               $end_index   = strpos( $split_arr, '"' );
-               return substr( $split_arr, 0, $end_index );
-       }
-
-       /**
-        * Retrieves block content from the rendered block string
-        * (i.e. what's wrapped by the block wrapper `<div />`).
-        *
-        * @param string $block String of rendered block to check.
-        */
-       private function get_content_from_block( $block ) {
-               $start_index = strpos( $block, '>' ) + 1; // First occurrence of '>'.
-               $split_arr   = substr( $block, $start_index );
-               $end_index   = strrpos( $split_arr, '<' ); // Last occurrence of '<'.
-               return substr( $split_arr, 0, $end_index ); // String between first '>' and last '<'.
-       }
-
-       /**
-        * Returns the rendered output for the current block.
-        *
-        * @param array $block Block to render.
-        * @return string Rendered output for the current block.
-        */
-       private function render_example_block( $block ) {
-               WP_Block_Supports::init();
-               WP_Block_Supports::$block_to_render = $block;
-               $wrapper_attributes                 = get_block_wrapper_attributes(
-                       array(
-                               'class' => 'foo-bar-class',
-                               'style' => 'test: style;',
-                       )
-               );
-               return '<div ' . $wrapper_attributes . '>' . self::BLOCK_CONTENT . '</div>';
-       }
-
-       /**
-        * Runs assertions that the rendered output has expected class/style attrs.
-        *
-        * @param array  $block            Block to render.
-        * @param string $expected_classes Expected output class attr string.
-        * @param string $expected_styles  Expected output styles attr string.
-        */
-       private function assert_styles_and_classes_match( $block, $expected_classes, $expected_styles ) {
-               $styled_block = $this->render_example_block( $block );
-               $class_list   = $this->get_attribute_from_block( 'class', $styled_block );
-               $style_list   = $this->get_attribute_from_block( 'style', $styled_block );
-
-               $this->assertSame( $expected_classes, $class_list, 'Class list does not match expected classes' );
-               $this->assertSame( $expected_styles, $style_list, 'Style list does not match expected styles' );
-       }
-
-       /**
-        * Runs assertions that the rendered output has expected content and class/style attrs.
-        *
-        * @param array  $block            Block to render.
-        * @param string $expected_classes Expected output class attr string.
-        * @param string $expected_styles  Expected output styles attr string.
-        */
-       private function assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles ) {
-               $styled_block = $this->render_example_block( $block );
-
-               // Ensure blocks to not add extra whitespace.
-               $this->assertSame( $styled_block, trim( $styled_block ) );
-
-               $content    = $this->get_content_from_block( $styled_block );
-               $class_list = $this->get_attribute_from_block( 'class', $styled_block );
-               $style_list = $this->get_attribute_from_block( 'style', $styled_block );
-
-               $this->assertSame( self::BLOCK_CONTENT, $content, 'Block content does not match expected content' );
-               $this->assertSameSets(
-                       explode( ' ', $expected_classes ),
-                       explode( ' ', $class_list ),
-                       'Class list does not match expected classes'
-               );
-               $this->assertSame(
-                       array_map( 'trim', explode( ';', $expected_styles ) ),
-                       array_map( 'trim', explode( ';', $style_list ) ),
-                       'Style list does not match expected styles'
-               );
-       }
-
-       /**
-        * Tests color support for named color support for named colors.
-        */
-       public function test_named_color_support() {
-               $block_type_settings = array(
-                       'attributes'      => array(),
-                       'supports'        => array(
-                               'color' => true,
-                       ),
-                       'render_callback' => true,
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'textColor'       => 'red',
-                               'backgroundColor' => 'black',
-                               // The following should not be applied (subcatagories of color support).
-                               'gradient'        => 'some-gradient',
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example has-text-color has-red-color has-background has-black-background-color';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests color support for custom colors.
-        */
-       public function test_custom_color_support() {
-               $block_type_settings = array(
-                       'attributes'      => array(),
-                       'supports'        => array(
-                               'color' => true,
-                       ),
-                       'render_callback' => true,
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'style' => array(
-                                       'color' => array(
-                                               'text'       => '#000',
-                                               'background' => '#fff',
-                                               // The following should not be applied (subcatagories of color support).
-                                               'gradient'   => 'some-gradient',
-                                               'style'      => array( 'color' => array( 'link' => '#fff' ) ),
-                                       ),
-                               ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_styles  = 'test: style; color: #000; background-color: #fff;';
-               $expected_classes = 'foo-bar-class wp-block-example has-text-color has-background';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests gradient color support for named gradients.
-        */
-       public function test_named_gradient_support() {
-               $block_type_settings = array(
-                       'attributes'      => array(),
-                       'supports'        => array(
-                               'color' => array(
-                                       'gradients' => true,
-                               ),
-                       ),
-                       'render_callback' => true,
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'gradient' => 'red',
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example has-background has-red-gradient-background';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests gradient color support for custom gradients.
-        */
-       public function test_custom_gradient_support() {
-               $block_type_settings = array(
-                       'attributes'      => array(),
-                       'supports'        => array(
-                               'color' => array(
-                                       'gradients' => true,
-                               ),
-                       ),
-                       'render_callback' => true,
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'style' => array( 'color' => array( 'gradient' => 'some-gradient-style' ) ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example has-background';
-               $expected_styles  = 'test: style; background: some-gradient-style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests that style attributes for colors are not applied without the support flag.
-        */
-       public function test_color_unsupported() {
-               $block_type_settings = array(
-                       'attributes'      => array(),
-                       'supports'        => array(),
-                       'render_callback' => true,
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'textColor'       => 'red',
-                               'backgroundColor' => 'black',
-                               'style'           => array(
-                                       'color' => array(
-                                               'text'       => '#000',
-                                               'background' => '#fff',
-                                               'link'       => '#ggg',
-                                               'gradient'   => 'some-gradient',
-                                       ),
-                               ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests support for named font sizes.
-        */
-       public function test_named_font_size() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'typography' => array(
-                                       'fontSize' => true,
-                               ),
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'fontSize' => 'large',
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example has-large-font-size';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests support for custom font sizes.
-        */
-       public function test_custom_font_size() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'typography' => array(
-                                       'fontSize' => true,
-                               ),
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'style' => array( 'typography' => array( 'fontSize' => '10px' ) ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example';
-               $expected_styles  = 'test: style; font-size: 10px;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests that font size attributes are not applied without support flag.
-        */
-       public function test_font_size_unsupported() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'fontSize' => 'large',
-                               'style'    => array( 'typography' => array( 'fontSize' => '10' ) ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests line height support.
-        */
-       public function test_line_height() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'typography' => array(
-                                       'lineHeight' => true,
-                               ),
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'style' => array( 'typography' => array( 'lineHeight' => '10' ) ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example';
-               $expected_styles  = 'test: style; line-height: 10;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests line height not applied without support flag.
-        */
-       public function test_line_height_unsupported() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'style' => array( 'typography' => array( 'lineHeight' => '10' ) ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests support for block alignment.
-        */
-       public function test_block_alignment() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'align' => true,
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'align' => 'wide',
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example alignwide';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests block alignment requires support to be added.
-        */
-       public function test_block_alignment_unsupported() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'align' => 'wide',
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example';
-               $expected_styles  = 'test: style;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests all support flags together to ensure they work together as expected.
-        */
-       public function test_all_supported() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'color'      => array(
-                                       'gradients' => true,
-                                       'link'      => true,
-                               ),
-                               'typography' => array(
-                                       'fontSize'   => true,
-                                       'lineHeight' => true,
-                               ),
-                               'align'      => true,
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'align' => 'wide',
-                               'style' => array(
-                                       'color'      => array(
-                                               'text'       => '#000',
-                                               'background' => '#fff',
-                                               'style'      => array( 'color' => array( 'link' => '#fff' ) ),
-                                       ),
-                                       'typography' => array(
-                                               'lineHeight' => '20',
-                                               'fontSize'   => '10px',
-                                       ),
-                               ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example has-text-color has-background alignwide';
-               $expected_styles  = 'test: style; color: #000; background-color: #fff; font-size: 10px; line-height: 20;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests that only styles for the supported flag are added.
-        * Verify one support enabled does not imply multiple supports enabled.
-        */
-       public function test_one_supported() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'typography' => array(
-                                       'fontSize' => true,
-                               ),
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'align' => 'wide',
-                               'style' => array(
-                                       'color'      => array(
-                                               'text'       => '#000',
-                                               'background' => '#fff',
-                                               'gradient'   => 'some-gradient',
-                                               'style'      => array( 'color' => array( 'link' => '#fff' ) ),
-                                       ),
-                                       'typography' => array(
-                                               'lineHeight' => '20',
-                                               'fontSize'   => '10px',
-                                       ),
-                               ),
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_classes = 'foo-bar-class wp-block-example';
-               $expected_styles  = 'test: style; font-size: 10px;';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests custom classname server-side block support.
-        */
-       public function test_custom_classnames_support() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'className' => 'my-custom-classname',
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_styles  = 'test: style;';
-               $expected_classes = 'foo-bar-class wp-block-example my-custom-classname';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests custom classname server-side block support opt-out.
-        */
-       public function test_custom_classnames_support_opt_out() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'customClassName' => false,
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(
-                               'className' => 'my-custom-classname',
-                       ),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_styles  = 'test: style;';
-               $expected_classes = 'foo-bar-class wp-block-example';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Tests generated classname server-side block support opt-out.
-        */
-       public function test_generated_classnames_support_opt_out() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(
-                               'className' => false,
-                       ),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               $expected_styles  = 'test: style;';
-               $expected_classes = 'foo-bar-class';
-
-               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
-       }
-
-       /**
-        * Ensures libxml_internal_errors is being used instead of @ warning suppression
-        */
-       public function test_render_block_suppresses_warnings_without_at_suppression() {
-               $block_type_settings = array(
-                       'attributes' => array(),
-                       'supports'   => array(),
-               );
-               $this->register_block_type( 'core/example', $block_type_settings );
-
-               $block = array(
-                       'blockName'    => 'core/example',
-                       'attrs'        => array(),
-                       'innerBlock'   => array(),
-                       'innerContent' => array(),
-                       'innerHTML'    => array(),
-               );
-
-               // Custom error handler's see Warnings even if they are suppressed by the @ symbol.
-               $errors = array();
-               set_error_handler(
-                       function ( $errno = 0, $errstr = '' ) use ( &$errors ) {
-                               $errors[] = $errstr;
-                               return false;
-                       }
-               );
-
-               // HTML5 elements like <time> are not supported by the DOMDocument parser used by the block supports feature.
-               // This specific example is emitted by the "Display post date" setting in the latest-posts block.
-               apply_filters( 'render_block', '<div><time datetime="2020-06-18T04:01:43+10:00" class="wp-block-latest-posts__post-date">June 18, 2020</time></div>', $block );
-
-               restore_error_handler();
-
-               $this->assertEmpty( $errors, 'Libxml errors should be dropped.' );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksblocktyperegistryphp"></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/blocks/block-type-registry.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block-type-registry.php  2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block-type-registry.php    2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,191 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * WP_Block_Type_Registry Tests
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.0.0
- */
-
-/**
- * Tests for WP_Block_Type_Registry
- *
- * @since 5.0.0
- *
- * @group blocks
- */
-class WP_Test_Block_Type_Registry extends WP_UnitTestCase {
-
-       /**
-        * Fake block type registry.
-        *
-        * @since 5.0.0
-        * @var WP_Block_Type_Registry
-        */
-       private $registry = null;
-
-       /**
-        * Set up each test method.
-        *
-        * @since 5.0.0
-        */
-       public function setUp() {
-               parent::setUp();
-
-               $this->registry = new WP_Block_Type_Registry();
-       }
-
-       /**
-        * Tear down each test method.
-        *
-        * @since 5.0.0
-        */
-       public function tearDown() {
-               $this->registry = null;
-
-               parent::tearDown();
-       }
-
-       /**
-        * Should reject numbers
-        *
-        * @ticket 45097
-        *
-        * @expectedIncorrectUsage WP_Block_Type_Registry::register
-        */
-       public function test_invalid_non_string_names() {
-               $result = $this->registry->register( 1, array() );
-               $this->assertFalse( $result );
-       }
-
-       /**
-        * Should reject blocks without a namespace
-        *
-        * @ticket 45097
-        *
-        * @expectedIncorrectUsage WP_Block_Type_Registry::register
-        */
-       public function test_invalid_names_without_namespace() {
-               $result = $this->registry->register( 'paragraph', array() );
-               $this->assertFalse( $result );
-       }
-
-       /**
-        * Should reject blocks with invalid characters
-        *
-        * @ticket 45097
-        *
-        * @expectedIncorrectUsage WP_Block_Type_Registry::register
-        */
-       public function test_invalid_characters() {
-               $result = $this->registry->register( 'still/_doing_it_wrong', array() );
-               $this->assertFalse( $result );
-       }
-
-       /**
-        * Should reject blocks with uppercase characters
-        *
-        * @ticket 45097
-        *
-        * @expectedIncorrectUsage WP_Block_Type_Registry::register
-        */
-       public function test_uppercase_characters() {
-               $result = $this->registry->register( 'Core/Paragraph', array() );
-               $this->assertFalse( $result );
-       }
-
-       /**
-        * Should accept valid block names
-        *
-        * @ticket 45097
-        */
-       public function test_register_block_type() {
-               $name     = 'core/paragraph';
-               $settings = array(
-                       'icon' => 'editor-paragraph',
-               );
-
-               $block_type = $this->registry->register( $name, $settings );
-               $this->assertSame( $name, $block_type->name );
-               $this->assertSame( $settings['icon'], $block_type->icon );
-               $this->assertSame( $block_type, $this->registry->get_registered( $name ) );
-       }
-
-       /**
-        * Should fail to re-register the same block
-        *
-        * @ticket 45097
-        *
-        * @expectedIncorrectUsage WP_Block_Type_Registry::register
-        */
-       public function test_register_block_type_twice() {
-               $name     = 'core/paragraph';
-               $settings = array(
-                       'icon' => 'editor-paragraph',
-               );
-
-               $result = $this->registry->register( $name, $settings );
-               $this->assertNotFalse( $result );
-               $result = $this->registry->register( $name, $settings );
-               $this->assertFalse( $result );
-       }
-
-       /**
-        * Should accept a WP_Block_Type instance
-        *
-        * @ticket 45097
-        */
-       public function test_register_block_type_instance() {
-               $block_type = new WP_Fake_Block_Type( 'core/fake' );
-
-               $result = $this->registry->register( $block_type );
-               $this->assertSame( $block_type, $result );
-       }
-
-       /**
-        * Unregistering should fail if a block is not registered
-        *
-        * @ticket 45097
-        *
-        * @expectedIncorrectUsage WP_Block_Type_Registry::unregister
-        */
-       public function test_unregister_not_registered_block() {
-               $result = $this->registry->unregister( 'core/unregistered' );
-               $this->assertFalse( $result );
-       }
-
-       /**
-        * Should unregister existing blocks
-        *
-        * @ticket 45097
-        */
-       public function test_unregister_block_type() {
-               $name     = 'core/paragraph';
-               $settings = array(
-                       'icon' => 'editor-paragraph',
-               );
-
-               $this->registry->register( $name, $settings );
-               $block_type = $this->registry->unregister( $name );
-               $this->assertSame( $name, $block_type->name );
-               $this->assertSame( $settings['icon'], $block_type->icon );
-               $this->assertFalse( $this->registry->is_registered( $name ) );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_get_all_registered() {
-               $names    = array( 'core/paragraph', 'core/image', 'core/blockquote' );
-               $settings = array(
-                       'icon' => 'random',
-               );
-
-               foreach ( $names as $name ) {
-                       $this->registry->register( $name, $settings );
-               }
-
-               $registered = $this->registry->get_all_registered();
-               $this->assertSameSets( $names, array_keys( $registered ) );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksblocktypephp"></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/blocks/block-type.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block-type.php   2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block-type.php     2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,422 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * WP_Block_Type Tests
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.0.0
- */
-
-/**
- * Tests for WP_Block_Type
- *
- * @since 5.0.0
- *
- * @group blocks
- */
-class WP_Test_Block_Type extends WP_UnitTestCase {
-
-       /**
-        * Editor user ID.
-        *
-        * @since 5.0.0
-        * @var int
-        */
-       protected static $editor_user_id;
-
-       /**
-        * ID for a post containing blocks.
-        *
-        * @since 5.0.0
-        * @var int
-        */
-       protected static $post_with_blocks;
-
-       /**
-        * ID for a post without blocks.
-        *
-        * @since 5.0.0
-        * @var int
-        */
-       protected static $post_without_blocks;
-
-       /**
-        * Set up before class.
-        *
-        * @since 5.0.0
-        */
-       public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
-               self::$editor_user_id = $factory->user->create(
-                       array(
-                               'role' => 'editor',
-                       )
-               );
-
-               self::$post_with_blocks = $factory->post->create(
-                       array(
-                               'post_title'   => 'Example',
-                               'post_content' => "<!-- wp:core/text {\"dropCap\":true} -->\n<p class=\"has-drop-cap\">Tester</p>\n<!-- /wp:core/text -->",
-                       )
-               );
-
-               self::$post_without_blocks = $factory->post->create(
-                       array(
-                               'post_title'   => 'Example',
-                               'post_content' => 'Tester',
-                       )
-               );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_set_props() {
-               $name = 'core/fake';
-               $args = array(
-                       'render_callback' => array( $this, 'render_fake_block' ),
-                       'foo'             => 'bar',
-               );
-
-               $block_type = new WP_Block_Type( $name, $args );
-
-               $this->assertSame( $name, $block_type->name );
-               $this->assertSame( $args['render_callback'], $block_type->render_callback );
-               $this->assertSame( $args['foo'], $block_type->foo );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_render() {
-               $attributes = array(
-                       'foo' => 'bar',
-                       'bar' => 'foo',
-               );
-
-               $block_type = new WP_Block_Type(
-                       'core/fake',
-                       array(
-                               'render_callback' => array( $this, 'render_fake_block' ),
-                       )
-               );
-               $output     = $block_type->render( $attributes );
-               $this->assertSame( $attributes, json_decode( $output, true ) );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_render_with_content() {
-               $attributes = array(
-                       'foo' => 'bar',
-                       'bar' => 'foo',
-               );
-
-               $content = 'baz';
-
-               $expected = array_merge( $attributes, array( '_content' => $content ) );
-
-               $block_type = new WP_Block_Type(
-                       'core/fake',
-                       array(
-                               'render_callback' => array( $this, 'render_fake_block_with_content' ),
-                       )
-               );
-               $output     = $block_type->render( $attributes, $content );
-               $this->assertSame( $expected, json_decode( $output, true ) );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_render_for_static_block() {
-               $block_type = new WP_Block_Type( 'core/fake', array() );
-               $output     = $block_type->render();
-
-               $this->assertSame( '', $output );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_is_dynamic_for_static_block() {
-               $block_type = new WP_Block_Type( 'core/fake', array() );
-
-               $this->assertFalse( $block_type->is_dynamic() );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_is_dynamic_for_dynamic_block() {
-               $block_type = new WP_Block_Type(
-                       'core/fake',
-                       array(
-                               'render_callback' => array( $this, 'render_fake_block' ),
-                       )
-               );
-
-               $this->assertTrue( $block_type->is_dynamic() );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_prepare_attributes() {
-               $attributes = array(
-                       'correct'            => 'include',
-                       'wrongType'          => 5,
-                       'wrongTypeDefaulted' => 5,
-                       /* missingDefaulted */
-                       'undefined'          => 'include',
-                       'intendedNull'       => null,
-               );
-
-               $block_type = new WP_Block_Type(
-                       'core/fake',
-                       array(
-                               'attributes' => array(
-                                       'correct'            => array(
-                                               'type' => 'string',
-                                       ),
-                                       'wrongType'          => array(
-                                               'type' => 'string',
-                                       ),
-                                       'wrongTypeDefaulted' => array(
-                                               'type'    => 'string',
-                                               'default' => 'defaulted',
-                                       ),
-                                       'missingDefaulted'   => array(
-                                               'type'    => 'string',
-                                               'default' => 'define',
-                                       ),
-                                       'intendedNull'       => array(
-                                               'type'    => array( 'string', 'null' ),
-                                               'default' => 'wrong',
-                                       ),
-                               ),
-                       )
-               );
-
-               $prepared_attributes = $block_type->prepare_attributes_for_render( $attributes );
-
-               $this->assertEquals(
-                       array(
-                               'correct'            => 'include',
-                               /* wrongType */
-                               'wrongTypeDefaulted' => 'defaulted',
-                               'missingDefaulted'   => 'define',
-                               'undefined'          => 'include',
-                               'intendedNull'       => null,
-                       ),
-                       $prepared_attributes
-               );
-       }
-
-       /**
-        * @ticket 45145
-        */
-       function test_prepare_attributes_none_defined() {
-               $attributes = array( 'exists' => 'keep' );
-
-               $block_type = new WP_Block_Type( 'core/dummy', array() );
-
-               $prepared_attributes = $block_type->prepare_attributes_for_render( $attributes );
-
-               $this->assertSame( $attributes, $prepared_attributes );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_has_block_with_mixed_content() {
-               $mixed_post_content = 'before' .
-               '<!-- wp:core/fake --><!-- /wp:core/fake -->' .
-               '<!-- wp:core/fake_atts {"value":"b1"} --><!-- /wp:core/fake_atts -->' .
-               '<!-- wp:core/fake-child -->
-               <p>testing the test</p>
-               <!-- /wp:core/fake-child -->' .
-               'between' .
-               '<!-- wp:core/self-close-fake /-->' .
-               '<!-- wp:custom/fake {"value":"b2"} /-->' .
-               'after';
-
-               $this->assertTrue( has_block( 'core/fake', $mixed_post_content ) );
-
-               $this->assertTrue( has_block( 'core/fake_atts', $mixed_post_content ) );
-
-               $this->assertTrue( has_block( 'core/fake-child', $mixed_post_content ) );
-
-               $this->assertTrue( has_block( 'core/self-close-fake', $mixed_post_content ) );
-
-               $this->assertTrue( has_block( 'custom/fake', $mixed_post_content ) );
-
-               // checking for a partial block name should fail.
-               $this->assertFalse( has_block( 'core/fak', $mixed_post_content ) );
-
-               // checking for a wrong namespace should fail.
-               $this->assertFalse( has_block( 'custom/fake_atts', $mixed_post_content ) );
-
-               // checking for namespace only should not work. Or maybe ... ?
-               $this->assertFalse( has_block( 'core', $mixed_post_content ) );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_has_block_with_invalid_content() {
-               // some content with invalid HMTL comments and a single valid block.
-               $invalid_content = 'before' .
-               '<!- - wp:core/weird-space --><!-- /wp:core/weird-space -->' .
-               '<!--wp:core/untrimmed-left --><!-- /wp:core/untrimmed -->' .
-               '<!-- wp:core/fake --><!-- /wp:core/fake -->' .
-               '<!-- wp:core/untrimmed-right--><!-- /wp:core/untrimmed2 -->' .
-               'after';
-
-               $this->assertFalse( has_block( 'core/text', self::$post_without_blocks ) );
-
-               $this->assertFalse( has_block( 'core/weird-space', $invalid_content ) );
-
-               $this->assertFalse( has_block( 'core/untrimmed-left', $invalid_content ) );
-
-               $this->assertFalse( has_block( 'core/untrimmed-right', $invalid_content ) );
-
-               $this->assertTrue( has_block( 'core/fake', $invalid_content ) );
-       }
-
-       /**
-        * @ticket 45097
-        */
-       public function test_post_has_block() {
-               // should fail for a non-existent block `custom/fake`.
-               $this->assertFalse( has_block( 'custom/fake', self::$post_with_blocks ) );
-
-               // this functions should not work without the second param until the $post global is set.
-               $this->assertFalse( has_block( 'core/text' ) );
-               $this->assertFalse( has_block( 'core/fake' ) );
-
-               global $post;
-               $post = get_post( self::$post_with_blocks );
-
-               // check if the function correctly detects content from the $post global.
-               $this->assertTrue( has_block( 'core/text' ) );
-               // even if it detects a proper $post global it should still be false for a missing block.
-               $this->assertFalse( has_block( 'core/fake' ) );
-       }
-
-       public function test_post_has_block_serialized_name() {
-               $content = '<!-- wp:serialized /--><!-- wp:core/normalized /--><!-- wp:plugin/third-party /-->';
-
-               $this->assertTrue( has_block( 'core/serialized', $content ) );
-
-               /*
-                * Technically, `has_block` should receive a "full" (normalized, parsed)
-                * block name. But this test conforms to expected pre-5.3.1 behavior.
-                */
-               $this->assertTrue( has_block( 'serialized', $content ) );
-               $this->assertTrue( has_block( 'core/normalized', $content ) );
-               $this->assertTrue( has_block( 'normalized', $content ) );
-               $this->assertFalse( has_block( 'plugin/normalized', $content ) );
-               $this->assertFalse( has_block( 'plugin/serialized', $content ) );
-               $this->assertFalse( has_block( 'third-party', $content ) );
-               $this->assertFalse( has_block( 'core/third-party', $content ) );
-       }
-
-       /**
-        * Renders a test block without content.
-        *
-        * @since 5.0.0
-        *
-        * @param array $attributes Block attributes. Default empty array.
-        * @return string JSON encoded list of attributes.
-        */
-       public function render_fake_block( $attributes ) {
-               return json_encode( $attributes );
-       }
-
-       /**
-        * Renders a test block with content.
-        *
-        * @since 5.0.0
-        *
-        * @param array  $attributes Block attributes. Default empty array.
-        * @param string $content    Block content. Default empty string.
-        * @return string JSON encoded list of attributes.
-        */
-       public function render_fake_block_with_content( $attributes, $content ) {
-               $attributes['_content'] = $content;
-
-               return json_encode( $attributes );
-       }
-
-       /**
-        * @ticket 48529
-        */
-       public function test_register_block() {
-               $block_type = new WP_Block_Type(
-                       'core/fake',
-                       array(
-                               'title'       => 'Test title',
-                               'category'    => 'Test category',
-                               'parent'      => array( 'core/third-party' ),
-                               'icon'        => 'icon.png',
-                               'description' => 'test description',
-                               'keywords'    => array( 'test keyword' ),
-                               'textdomain'  => 'test_domain',
-                               'supports'    => array( 'alignment' => true ),
-                       )
-               );
-
-               $this->assertSame( 'Test title', $block_type->title );
-               $this->assertSame( 'Test category', $block_type->category );
-               $this->assertSameSets( array( 'core/third-party' ), $block_type->parent );
-               $this->assertSame( 'icon.png', $block_type->icon );
-               $this->assertSame( 'test description', $block_type->description );
-               $this->assertSameSets( array( 'test keyword' ), $block_type->keywords );
-               $this->assertSame( 'test_domain', $block_type->textdomain );
-               $this->assertSameSets( array( 'alignment' => true ), $block_type->supports );
-       }
-
-       /**
-        * Testing the block version.
-        *
-        * @ticket 43887
-        *
-        * @dataProvider data_block_version
-        *
-        * @param string|null $content  Content.
-        * @param int         $expected Expected block version.
-        */
-       public function test_block_version( $content, $expected ) {
-               $this->assertSame( $expected, block_version( $content ) );
-       }
-
-       /**
-        * Test cases for test_block_version().
-        *
-        * @since 5.0.0
-        *
-        * @return array {
-        *     @type array {
-        *         @type string|null Content.
-        *         @type int         Expected block version.
-        *     }
-        * }
-        */
-       public function data_block_version() {
-               return array(
-                       // Null.
-                       array( null, 0 ),
-                       // Empty post content.
-                       array( '', 0 ),
-                       // Post content without blocks.
-                       array( '<hr class="wp-block-separator" />', 0 ),
-                       // Post content with a block.
-                       array( '<!-- wp:core/separator -->', 1 ),
-                       // Post content with a fake block.
-                       array( '<!-- wp:core/fake --><!-- /wp:core/fake -->', 1 ),
-                       // Post content with an invalid block.
-                       array( '<!- - wp:core/separator -->', 0 ),
-               );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksblockphp"></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/blocks/block.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/block.php        2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/block.php  2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,631 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * WP_Block Tests
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.5.0
- */
-
-/**
- * Tests for WP_Block
- *
- * @since 5.5.0
- *
- * @group blocks
- */
-class WP_Block_Test extends WP_UnitTestCase {
-
-       /**
-        * Fake block type registry.
-        *
-        * @var WP_Block_Type_Registry
-        */
-       private $registry = null;
-
-       /**
-        * Set up each test method.
-        */
-       public function setUp() {
-               parent::setUp();
-
-               $this->registry = new WP_Block_Type_Registry();
-       }
-
-       /**
-        * Tear down each test method.
-        */
-       public function tearDown() {
-               $this->registry = null;
-
-               parent::tearDown();
-       }
-
-       function filter_render_block( $content, $parsed_block ) {
-               return 'Original: "' . $content . '", from block "' . $parsed_block['blockName'] . '"';
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_constructor_assigns_properties_from_parsed_block() {
-               $this->registry->register( 'core/example', array() );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame( $parsed_block, $block->parsed_block );
-               $this->assertSame( $parsed_block['blockName'], $block->name );
-               $this->assertSame( $parsed_block['attrs'], $block->attributes );
-               $this->assertSame( $parsed_block['innerContent'], $block->inner_content );
-               $this->assertSame( $parsed_block['innerHTML'], $block->inner_html );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_constructor_assigns_block_type_from_registry() {
-               $block_type_settings = array(
-                       'attributes' => array(
-                               'defaulted' => array(
-                                       'type'    => 'number',
-                                       'default' => 10,
-                               ),
-                       ),
-               );
-               $this->registry->register( 'core/example', $block_type_settings );
-
-               $parsed_block = array( 'blockName' => 'core/example' );
-               $context      = array();
-               $block        = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertInstanceOf( WP_Block_Type::class, $block->block_type );
-               $this->assertSame(
-                       $block_type_settings['attributes'],
-                       $block->block_type->attributes
-               );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_lazily_assigns_attributes_with_defaults() {
-               $this->registry->register(
-                       'core/example',
-                       array(
-                               'attributes' => array(
-                                       'defaulted' => array(
-                                               'type'    => 'number',
-                                               'default' => 10,
-                                       ),
-                               ),
-                       )
-               );
-
-               $parsed_block = array(
-                       'blockName' => 'core/example',
-                       'attrs'     => array(
-                               'explicit' => 20,
-                       ),
-               );
-               $context      = array();
-               $block        = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame(
-                       array(
-                               'explicit'  => 20,
-                               'defaulted' => 10,
-                       ),
-                       $block->attributes
-               );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_lazily_assigns_attributes_with_only_defaults() {
-               $this->registry->register(
-                       'core/example',
-                       array(
-                               'attributes' => array(
-                                       'defaulted' => array(
-                                               'type'    => 'number',
-                                               'default' => 10,
-                                       ),
-                               ),
-                       )
-               );
-
-               $parsed_block = array(
-                       'blockName' => 'core/example',
-                       'attrs'     => array(),
-               );
-               $context      = array();
-               $block        = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame( array( 'defaulted' => 10 ), $block->attributes );
-               // Intentionally call a second time, to ensure property was assigned.
-               $this->assertSame( array( 'defaulted' => 10 ), $block->attributes );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_constructor_assigns_context_from_block_type() {
-               $this->registry->register(
-                       'core/example',
-                       array(
-                               'uses_context' => array( 'requested' ),
-                       )
-               );
-
-               $parsed_block = array( 'blockName' => 'core/example' );
-               $context      = array(
-                       'requested'   => 'included',
-                       'unrequested' => 'not included',
-               );
-               $block        = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame( array( 'requested' => 'included' ), $block->context );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_constructor_maps_inner_blocks() {
-               $this->registry->register( 'core/example', array() );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertCount( 1, $block->inner_blocks );
-               $this->assertInstanceOf( WP_Block::class, $block->inner_blocks[0] );
-               $this->assertSame( 'core/example', $block->inner_blocks[0]->name );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_constructor_prepares_context_for_inner_blocks() {
-               $this->registry->register(
-                       'core/outer',
-                       array(
-                               'attributes'       => array(
-                                       'recordId' => array(
-                                               'type' => 'number',
-                                       ),
-                               ),
-                               'provides_context' => array(
-                                       'core/recordId' => 'recordId',
-                               ),
-                       )
-               );
-               $this->registry->register(
-                       'core/inner',
-                       array(
-                               'uses_context' => array( 'core/recordId' ),
-                       )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:outer {"recordId":10} --><!-- wp:inner /--><!-- /wp:outer -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array( 'unrequested' => 'not included' );
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertCount( 0, $block->context );
-               $this->assertSame(
-                       array( 'core/recordId' => 10 ),
-                       $block->inner_blocks[0]->context
-               );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_constructor_assigns_merged_context() {
-               $this->registry->register(
-                       'core/example',
-                       array(
-                               'attributes'       => array(
-                                       'value' => array(
-                                               'type' => array( 'string', 'null' ),
-                                       ),
-                               ),
-                               'provides_context' => array(
-                                       'core/value' => 'value',
-                               ),
-                               'uses_context'     => array( 'core/value' ),
-                       )
-               );
-
-               $parsed_blocks = parse_blocks(
-                       '<!-- wp:example {"value":"merged"} -->' .
-                       '<!-- wp:example {"value":null} -->' .
-                       '<!-- wp:example /-->' .
-                       '<!-- /wp:example -->' .
-                       '<!-- /wp:example -->'
-               );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array( 'core/value' => 'original' );
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame(
-                       array( 'core/value' => 'original' ),
-                       $block->context
-               );
-               $this->assertSame(
-                       array( 'core/value' => 'merged' ),
-                       $block->inner_blocks[0]->context
-               );
-               $this->assertSame(
-                       array( 'core/value' => null ),
-                       $block->inner_blocks[0]->inner_blocks[0]->context
-               );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_render_static_block_type_returns_own_content() {
-               $this->registry->register( 'core/static', array() );
-               $this->registry->register(
-                       'core/dynamic',
-                       array(
-                               'render_callback' => function() {
-                                       return 'b';
-                               },
-                       )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:static -->a<!-- wp:dynamic /-->c<!-- /wp:static -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame( 'abc', $block->render() );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_render_passes_block_for_render_callback() {
-               $this->registry->register(
-                       'core/greeting',
-                       array(
-                               'render_callback' => function( $attributes, $content, $block ) {
-                                       return sprintf( 'Hello from %s', $block->name );
-                               },
-                       )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:greeting /-->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame( 'Hello from core/greeting', $block->render() );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_render_applies_render_block_filter() {
-               $this->registry->register( 'core/example', array() );
-
-               add_filter( 'render_block', array( $this, 'filter_render_block' ), 10, 2 );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example -->Static<!-- wp:example -->Inner<!-- /wp:example --><!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $rendered_content = $block->render();
-
-               remove_filter( 'render_block', array( $this, 'filter_render_block' ) );
-
-               $this->assertSame( 'Original: "StaticOriginal: "Inner", from block "core/example"", from block "core/example"', $rendered_content );
-       }
-
-       /**
-        * @ticket 46187
-        */
-       function test_render_applies_dynamic_render_block_filter() {
-               $this->registry->register( 'core/example', array() );
-
-               add_filter( 'render_block_core/example', array( $this, 'filter_render_block' ), 10, 2 );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example -->Static<!-- wp:example -->Inner<!-- /wp:example --><!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $rendered_content = $block->render();
-
-               remove_filter( 'render_block_core/example', array( $this, 'filter_render_block' ) );
-
-               $this->assertSame( 'Original: "StaticOriginal: "Inner", from block "core/example"", from block "core/example"', $rendered_content );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_passes_attributes_to_render_callback() {
-               $this->registry->register(
-                       'core/greeting',
-                       array(
-                               'attributes'      => array(
-                                       'toWhom'      => array(
-                                               'type' => 'string',
-                                       ),
-                                       'punctuation' => array(
-                                               'type'    => 'string',
-                                               'default' => '!',
-                                       ),
-                               ),
-                               'render_callback' => function( $block_attributes ) {
-                                       return sprintf(
-                                               'Hello %s%s',
-                                               $block_attributes['toWhom'],
-                                               $block_attributes['punctuation']
-                                       );
-                               },
-                       )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:greeting {"toWhom":"world"} /-->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame( 'Hello world!', $block->render() );
-       }
-
-       /**
-        * @ticket 49927
-        */
-       function test_passes_content_to_render_callback() {
-               $this->registry->register(
-                       'core/outer',
-                       array(
-                               'render_callback' => function( $block_attributes, $content ) {
-                                       return $content;
-                               },
-                       )
-               );
-               $this->registry->register(
-                       'core/inner',
-                       array(
-                               'render_callback' => function() {
-                                       return 'b';
-                               },
-                       )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:outer -->a<!-- wp:inner /-->c<!-- /wp:outer -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array();
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-
-               $this->assertSame( 'abc', $block->render() );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_build_query_vars_from_query_block() {
-               $this->registry->register(
-                       'core/example',
-                       array( 'uses_context' => array( 'query' ) )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array(
-                       'query' => array(
-                               'postType'    => 'page',
-                               'exclude'     => array( 1, 2 ),
-                               'categoryIds' => array( 56 ),
-                               'orderBy'     => 'title',
-                               'tagIds'      => array( 3, 11, 10 ),
-                       ),
-               );
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-               $query         = build_query_vars_from_query_block( $block, 1 );
-
-               $this->assertSame(
-                       $query,
-                       array(
-                               'post_type'    => 'page',
-                               'order'        => 'DESC',
-                               'orderby'      => 'title',
-                               'post__not_in' => array( 1, 2 ),
-                               'category__in' => array( 56 ),
-                               'tag__in'      => array( 3, 11, 10 ),
-                       )
-               );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_build_query_vars_from_query_block_no_context() {
-               $this->registry->register( 'core/example', array() );
-
-               $parsed_blocks    = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
-               $parsed_block     = $parsed_blocks[0];
-               $block_no_context = new WP_Block( $parsed_block, array(), $this->registry );
-               $query            = build_query_vars_from_query_block( $block_no_context, 1 );
-
-               $this->assertSame(
-                       $query,
-                       array(
-                               'post_type'    => 'post',
-                               'order'        => 'DESC',
-                               'orderby'      => 'date',
-                               'post__not_in' => array(),
-                       )
-               );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_build_query_vars_from_query_block_first_page() {
-               $this->registry->register(
-                       'core/example',
-                       array( 'uses_context' => array( 'query' ) )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array(
-                       'query' => array(
-                               'perPage' => 2,
-                               'offset'  => 0,
-                       ),
-               );
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-               $query         = build_query_vars_from_query_block( $block, 1 );
-
-               $this->assertSame(
-                       $query,
-                       array(
-                               'post_type'      => 'post',
-                               'order'          => 'DESC',
-                               'orderby'        => 'date',
-                               'post__not_in'   => array(),
-                               'offset'         => 0,
-                               'posts_per_page' => 2,
-                       )
-               );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_build_query_vars_from_query_block_page_no_offset() {
-               $this->registry->register(
-                       'core/example',
-                       array( 'uses_context' => array( 'query' ) )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array(
-                       'query' => array(
-                               'perPage' => 5,
-                               'offset'  => 0,
-                       ),
-               );
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-               $query         = build_query_vars_from_query_block( $block, 3 );
-               $this->assertSame(
-                       $query,
-                       array(
-                               'post_type'      => 'post',
-                               'order'          => 'DESC',
-                               'orderby'        => 'date',
-                               'post__not_in'   => array(),
-                               'offset'         => 10,
-                               'posts_per_page' => 5,
-                       )
-               );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_build_query_vars_from_query_block_page_with_offset() {
-               $this->registry->register(
-                       'core/example',
-                       array( 'uses_context' => array( 'query' ) )
-               );
-
-               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
-               $parsed_block  = $parsed_blocks[0];
-               $context       = array(
-                       'query' => array(
-                               'perPage' => 5,
-                               'offset'  => 2,
-                       ),
-               );
-               $block         = new WP_Block( $parsed_block, $context, $this->registry );
-               $query         = build_query_vars_from_query_block( $block, 3 );
-               $this->assertSame(
-                       $query,
-                       array(
-                               'post_type'      => 'post',
-                               'order'          => 'DESC',
-                               'orderby'        => 'date',
-                               'post__not_in'   => array(),
-                               'offset'         => 12,
-                               'posts_per_page' => 5,
-                       )
-               );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_block_has_support() {
-               $this->registry->register(
-                       'core/example',
-                       array(
-                               'supports' => array(
-                                       'align'    => array( 'wide', 'full' ),
-                                       'fontSize' => true,
-                                       'color'    => array(
-                                               'link'     => true,
-                                               'gradient' => false,
-                                       ),
-                               ),
-                       )
-               );
-               $block_type    = $this->registry->get_registered( 'core/example' );
-               $align_support = block_has_support( $block_type, array( 'align' ) );
-               $this->assertTrue( $align_support );
-               $gradient_support = block_has_support( $block_type, array( 'color', 'gradient' ) );
-               $this->assertFalse( $gradient_support );
-               $link_support = block_has_support( $block_type, array( 'color', 'link' ), false );
-               $this->assertTrue( $link_support );
-               $text_support = block_has_support( $block_type, array( 'color', 'text' ) );
-               $this->assertFalse( $text_support );
-               $font_nested = block_has_support( $block_type, array( 'fontSize', 'nested' ) );
-               $this->assertFalse( $font_nested );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_block_has_support_no_supports() {
-               $this->registry->register( 'core/example', array() );
-               $block_type  = $this->registry->get_registered( 'core/example' );
-               $has_support = block_has_support( $block_type, array( 'color' ) );
-               $this->assertFalse( $has_support );
-       }
-
-       /**
-        * @ticket 52991
-        */
-       public function test_block_has_support_provided_defaults() {
-               $this->registry->register(
-                       'core/example',
-                       array(
-                               'supports' => array(
-                                       'color' => array(
-                                               'gradient' => false,
-                                       ),
-                               ),
-                       )
-               );
-               $block_type    = $this->registry->get_registered( 'core/example' );
-               $align_support = block_has_support( $block_type, array( 'align' ), true );
-               $this->assertTrue( $align_support );
-               $gradient_support = block_has_support( $block_type, array( 'color', 'gradient' ), true );
-               $this->assertFalse( $gradient_support );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblockscontextphpfromrev51490trunktestsphpunittestsblocksblockcontextphp"></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/blocks/context.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block-context.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/context.php                              (rev 0)
+++ trunk/tests/phpunit/tests/blocks/context.php        2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,215 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Block context tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.5.0
+ */
+
+/**
+ * Tests for block context functions.
+ *
+ * @since 5.5.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_Context extends WP_UnitTestCase {
+
+       /**
+        * Registered block names.
+        *
+        * @var string[]
+        */
+       private $registered_block_names = array();
+
+       /**
+        * Sets up each test method.
+        */
+       public function setUp() {
+               global $post;
+
+               parent::setUp();
+
+               $args = array(
+                       'post_content' => 'example',
+                       'post_excerpt' => '',
+               );
+
+               $post = $this->factory()->post->create_and_get( $args );
+               setup_postdata( $post );
+       }
+
+       /**
+        * Tear down each test method.
+        */
+       public function tearDown() {
+               while ( ! empty( $this->registered_block_names ) ) {
+                       $block_name = array_pop( $this->registered_block_names );
+                       unregister_block_type( $block_name );
+               }
+
+               parent::tearDown();
+       }
+
+       /**
+        * Registers a block type.
+        *
+        * @param string|WP_Block_Type $name Block type name including namespace, or alternatively a
+        *                                   complete WP_Block_Type instance. In case a WP_Block_Type
+        *                                   is provided, the $args parameter will be ignored.
+        * @param array                $args {
+        *     Optional. Array of block type arguments. Any arguments may be defined, however the
+        *     ones described below are supported by default. Default empty array.
+        *
+        *     @type callable $render_callback Callback used to render blocks of this block type.
+        * }
+        */
+       protected function register_block_type( $name, $args ) {
+               register_block_type( $name, $args );
+
+               $this->registered_block_names[] = $name;
+       }
+
+       /**
+        * Tests that a block which provides context makes that context available to
+        * its inner blocks.
+        *
+        * @ticket 49927
+        */
+       function test_provides_block_context() {
+               $provided_context = array();
+
+               $this->register_block_type(
+                       'gutenberg/test-context-provider',
+                       array(
+                               'attributes'       => array(
+                                       'contextWithAssigned'   => array(
+                                               'type' => 'number',
+                                       ),
+                                       'contextWithDefault'    => array(
+                                               'type'    => 'number',
+                                               'default' => 0,
+                                       ),
+                                       'contextWithoutDefault' => array(
+                                               'type' => 'number',
+                                       ),
+                                       'contextNotRequested'   => array(
+                                               'type' => 'number',
+                                       ),
+                               ),
+                               'provides_context' => array(
+                                       'gutenberg/contextWithAssigned'   => 'contextWithAssigned',
+                                       'gutenberg/contextWithDefault'    => 'contextWithDefault',
+                                       'gutenberg/contextWithoutDefault' => 'contextWithoutDefault',
+                                       'gutenberg/contextNotRequested'   => 'contextNotRequested',
+                               ),
+                       )
+               );
+
+               $this->register_block_type(
+                       'gutenberg/test-context-consumer',
+                       array(
+                               'uses_context'    => array(
+                                       'gutenberg/contextWithDefault',
+                                       'gutenberg/contextWithAssigned',
+                                       'gutenberg/contextWithoutDefault',
+                               ),
+                               'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
+                                       $provided_context[] = $block->context;
+
+                                       return '';
+                               },
+                       )
+               );
+
+               $parsed_blocks = parse_blocks(
+                       '<!-- wp:gutenberg/test-context-provider {"contextWithAssigned":10} -->' .
+                       '<!-- wp:gutenberg/test-context-consumer /-->' .
+                       '<!-- /wp:gutenberg/test-context-provider -->'
+               );
+
+               render_block( $parsed_blocks[0] );
+
+               $this->assertSame(
+                       array(
+                               'gutenberg/contextWithDefault'  => 0,
+                               'gutenberg/contextWithAssigned' => 10,
+                       ),
+                       $provided_context[0]
+               );
+       }
+
+       /**
+        * Tests that a block can receive default-provided context through
+        * render_block.
+        *
+        * @ticket 49927
+        */
+       function test_provides_default_context() {
+               global $post;
+
+               $provided_context = array();
+
+               $this->register_block_type(
+                       'gutenberg/test-context-consumer',
+                       array(
+                               'uses_context'    => array( 'postId', 'postType' ),
+                               'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
+                                       $provided_context[] = $block->context;
+
+                                       return '';
+                               },
+                       )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:gutenberg/test-context-consumer /-->' );
+
+               render_block( $parsed_blocks[0] );
+
+               $this->assertSame(
+                       array(
+                               'postId'   => $post->ID,
+                               'postType' => $post->post_type,
+                       ),
+                       $provided_context[0]
+               );
+       }
+
+       /**
+        * Tests that default block context can be filtered.
+        *
+        * @ticket 49927
+        */
+       function test_default_context_is_filterable() {
+               $provided_context = array();
+
+               $this->register_block_type(
+                       'gutenberg/test-context-consumer',
+                       array(
+                               'uses_context'    => array( 'example' ),
+                               'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
+                                       $provided_context[] = $block->context;
+
+                                       return '';
+                               },
+                       )
+               );
+
+               $filter_block_context = function( $context ) {
+                       $context['example'] = 'ok';
+                       return $context;
+               };
+
+               $parsed_blocks = parse_blocks( '<!-- wp:gutenberg/test-context-consumer /-->' );
+
+               add_filter( 'render_block_context', $filter_block_context );
+
+               render_block( $parsed_blocks[0] );
+
+               remove_filter( 'render_block_context', $filter_block_context );
+
+               $this->assertSame( array( 'example' => 'ok' ), $provided_context[0] );
+       }
+
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblockseditorphpfromrev51490trunktestsphpunittestsblocksblockeditorphp"></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/blocks/editor.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block-editor.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/editor.php                               (rev 0)
+++ trunk/tests/phpunit/tests/blocks/editor.php 2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,511 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Block editor tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.5.0
+ */
+
+/**
+ * Tests for the block editor methods.
+ *
+ * @since 5.5.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_Editor extends WP_UnitTestCase {
+
+       /**
+        * Sets up each test method.
+        */
+       public function setUp() {
+               global $post;
+
+               parent::setUp();
+
+               $args = array(
+                       'post_title' => 'Example',
+               );
+
+               $post = $this->factory()->post->create_and_get( $args );
+
+               global $wp_rest_server;
+               $wp_rest_server = new Spy_REST_Server;
+               do_action( 'rest_api_init', $wp_rest_server );
+       }
+
+       public function tearDown() {
+               /** @var WP_REST_Server $wp_rest_server */
+               global $wp_rest_server;
+               $wp_rest_server = null;
+               parent::tearDown();
+       }
+
+       function filter_set_block_categories_post( $block_categories, $post ) {
+               if ( empty( $post ) ) {
+                       return $block_categories;
+               }
+
+               return array(
+                       array(
+                               'slug'  => 'filtered-category',
+                               'title' => 'Filtered Category',
+                               'icon'  => null,
+                       ),
+               );
+       }
+
+       function filter_set_allowed_block_types_post( $allowed_block_types, $post ) {
+               if ( empty( $post ) ) {
+                       return $allowed_block_types;
+               }
+
+               return array( 'test/filtered-block' );
+       }
+
+       function filter_set_block_editor_settings_post( $editor_settings, $post ) {
+               if ( empty( $post ) ) {
+                       return $allowed_block_types;
+               }
+
+               return array(
+                       'filter' => 'deprecated',
+               );
+       }
+
+       /**
+        * @ticket 52920
+        */
+       function test_block_editor_context_no_settings() {
+               $context = new WP_Block_Editor_Context();
+
+               $this->assertNull( $context->post );
+       }
+
+       /**
+        * @ticket 52920
+        */
+       function test_block_editor_context_post() {
+               $context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
+
+               $this->assertSame( get_post(), $context->post );
+       }
+
+       /**
+        * @ticket 52920
+        * @expectedDeprecated block_categories
+        */
+       function test_get_block_categories_deprecated_filter_post_object() {
+               add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 );
+
+               $block_categories = get_block_categories( get_post() );
+
+               remove_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ) );
+
+               $this->assertSameSets(
+                       array(
+                               array(
+                                       'slug'  => 'filtered-category',
+                                       'title' => 'Filtered Category',
+                                       'icon'  => null,
+                               ),
+                       ),
+                       $block_categories
+               );
+       }
+
+       /**
+        * @ticket 52920
+        * @expectedDeprecated block_categories
+        */
+       function test_get_block_categories_deprecated_filter_post_editor() {
+               add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 );
+
+               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
+               $block_categories    = get_block_categories( $post_editor_context );
+
+               remove_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ) );
+
+               $this->assertSameSets(
+                       array(
+                               array(
+                                       'slug'  => 'filtered-category',
+                                       'title' => 'Filtered Category',
+                                       'icon'  => null,
+                               ),
+                       ),
+                       $block_categories
+               );
+       }
+
+       /**
+        * @ticket 52920
+        */
+       function test_get_allowed_block_types_default() {
+               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
+               $allowed_block_types = get_allowed_block_types( $post_editor_context );
+
+               $this->assertTrue( $allowed_block_types );
+       }
+
+       /**
+        * @ticket 52920
+        * @expectedDeprecated allowed_block_types
+        */
+       function test_get_allowed_block_types_deprecated_filter_post_editor() {
+               add_filter( 'allowed_block_types', array( $this, 'filter_set_allowed_block_types_post' ), 10, 2 );
+
+               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
+               $allowed_block_types = get_allowed_block_types( $post_editor_context );
+
+               remove_filter( 'allowed_block_types', array( $this, 'filter_set_allowed_block_types_post' ) );
+
+               $this->assertSameSets( array( 'test/filtered-block' ), $allowed_block_types );
+       }
+
+       /**
+        * @ticket 52920
+        */
+       function test_get_default_block_editor_settings() {
+               $settings = get_default_block_editor_settings();
+
+               $this->assertCount( 16, $settings );
+               $this->assertFalse( $settings['alignWide'] );
+               $this->assertIsArray( $settings['allowedMimeTypes'] );
+               $this->assertTrue( $settings['allowedBlockTypes'] );
+               $this->assertSameSets(
+                       array(
+                               array(
+                                       'slug'  => 'text',
+                                       'title' => 'Text',
+                                       'icon'  => null,
+                               ),
+                               array(
+                                       'slug'  => 'media',
+                                       'title' => 'Media',
+                                       'icon'  => null,
+                               ),
+                               array(
+                                       'slug'  => 'design',
+                                       'title' => 'Design',
+                                       'icon'  => null,
+                               ),
+                               array(
+                                       'slug'  => 'widgets',
+                                       'title' => 'Widgets',
+                                       'icon'  => null,
+                               ),
+                               array(
+                                       'slug'  => 'theme',
+                                       'title' => 'Theme',
+                                       'icon'  => null,
+                               ),
+                               array(
+                                       'slug'  => 'embed',
+                                       'title' => 'Embeds',
+                                       'icon'  => null,
+                               ),
+                               array(
+                                       'slug'  => 'reusable',
+                                       'title' => 'Reusable Blocks',
+                                       'icon'  => null,
+                               ),
+                       ),
+                       $settings['blockCategories']
+               );
+               $this->assertFalse( $settings['disableCustomColors'] );
+               $this->assertFalse( $settings['disableCustomFontSizes'] );
+               $this->assertFalse( $settings['disableCustomGradients'] );
+               $this->assertFalse( $settings['enableCustomLineHeight'] );
+               $this->assertFalse( $settings['enableCustomSpacing'] );
+               $this->assertFalse( $settings['enableCustomUnits'] );
+               $this->assertFalse( $settings['isRTL'] );
+               $this->assertSame( 'large', $settings['imageDefaultSize'] );
+               $this->assertSameSets(
+                       array(
+                               array(
+                                       'width'  => 150,
+                                       'height' => 150,
+                                       'crop'   => true,
+                               ),
+                               array(
+                                       'width'  => 300,
+                                       'height' => 300,
+                                       'crop'   => false,
+                               ),
+                               array(
+                                       'width'  => 1024,
+                                       'height' => 1024,
+                                       'crop'   => false,
+                               ),
+                       ),
+                       $settings['imageDimensions']
+               );
+               $this->assertTrue( $settings['imageEditing'] );
+               $this->assertSameSets(
+                       array(
+                               array(
+                                       'slug' => 'full',
+                                       'name' => 'Full Size',
+                               ),
+                               array(
+                                       'slug' => 'large',
+                                       'name' => 'Large',
+                               ),
+                               array(
+                                       'slug' => 'medium',
+                                       'name' => 'Medium',
+                               ),
+                               array(
+                                       'slug' => 'thumbnail',
+                                       'name' => 'Thumbnail',
+                               ),
+                       ),
+                       $settings['imageSizes']
+               );
+               $this->assertIsInt( $settings['maxUploadFileSize'] );
+       }
+
+       /**
+        * @ticket 53397
+        */
+       function test_get_legacy_widget_block_editor_settings() {
+               $settings = get_legacy_widget_block_editor_settings();
+               $this->assertCount( 1, $settings );
+               $this->assertSameSets(
+                       array(
+                               'archives',
+                               'block',
+                               'calendar',
+                               'categories',
+                               'custom_html',
+                               'media_audio',
+                               'media_gallery',
+                               'media_image',
+                               'media_video',
+                               'pages',
+                               'recent-comments',
+                               'recent-posts',
+                               'rss',
+                               'search',
+                               'tag_cloud',
+                               'text',
+                       ),
+                       $settings['widgetTypesToHideFromLegacyWidgetBlock']
+               );
+       }
+
+       /**
+        * @ticket 52920
+        */
+       function test_get_block_editor_settings_overrides_default_settings_all_editors() {
+               function filter_allowed_block_types_my_editor() {
+                       return array( 'test/filtered-my-block' );
+               }
+               function filter_block_categories_my_editor() {
+                       return array(
+                               array(
+                                       'slug'  => 'filtered-my-category',
+                                       'title' => 'Filtered My Category',
+                                       'icon'  => null,
+                               ),
+                       );
+               }
+               function filter_block_editor_settings_my_editor( $editor_settings ) {
+                       $editor_settings['maxUploadFileSize'] = 12345;
+
+                       return $editor_settings;
+               }
+
+               add_filter( 'allowed_block_types_all', 'filter_allowed_block_types_my_editor', 10, 1 );
+               add_filter( 'block_categories_all', 'filter_block_categories_my_editor', 10, 1 );
+               add_filter( 'block_editor_settings_all', 'filter_block_editor_settings_my_editor', 10, 1 );
+
+               $my_editor_context = new WP_Block_Editor_Context();
+               $settings          = get_block_editor_settings( array(), $my_editor_context );
+
+               remove_filter( 'allowed_block_types_all', 'filter_allowed_block_types_my_editor' );
+               remove_filter( 'block_categories_all', 'filter_block_categories_my_editor' );
+               remove_filter( 'block_editor_settings_all', 'filter_block_editor_settings_my_editor' );
+
+               $this->assertSameSets( array( 'test/filtered-my-block' ), $settings['allowedBlockTypes'] );
+               $this->assertSameSets(
+                       array(
+                               array(
+                                       'slug'  => 'filtered-my-category',
+                                       'title' => 'Filtered My Category',
+                                       'icon'  => null,
+                               ),
+                       ),
+                       $settings['blockCategories']
+               );
+               $this->assertSame( 12345, $settings['maxUploadFileSize'] );
+       }
+
+       /**
+        * @ticket 53458
+        */
+       function test_get_block_editor_settings_theme_json_settings() {
+               switch_theme( 'block-theme' );
+
+               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
+
+               $settings = get_block_editor_settings( array(), $post_editor_context );
+
+               // Related entry in theme.json: settings.color.palette
+               $this->assertSameSetsWithIndex(
+                       array(
+                               array(
+                                       'slug'  => 'light',
+                                       'name'  => 'Light',
+                                       'color' => '#f5f7f9',
+                               ),
+                               array(
+                                       'slug'  => 'dark',
+                                       'name'  => 'Dark',
+                                       'color' => '#000',
+                               ),
+                       ),
+                       $settings['colors']
+               );
+               // settings.color.gradients
+               $this->assertSameSetsWithIndex(
+                       array(
+                               array(
+                                       'name'     => 'Custom gradient',
+                                       'gradient' => 'linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)',
+                                       'slug'     => 'custom-gradient',
+                               ),
+                       ),
+                       $settings['gradients']
+               );
+               // settings.typography.fontSizes
+               $this->assertSameSetsWithIndex(
+                       array(
+                               array(
+                                       'name' => 'Custom',
+                                       'slug' => 'custom',
+                                       'size' => '100px',
+                               ),
+                       ),
+                       $settings['fontSizes']
+               );
+               // settings.color.custom
+               $this->assertTrue( $settings['disableCustomColors'] );
+               // settings.color.customGradient
+               $this->assertTrue( $settings['disableCustomGradients'] );
+               // settings.typography.customFontSize
+               $this->assertTrue( $settings['disableCustomFontSizes'] );
+               // settings.typography.customLineHeight
+               $this->assertTrue( $settings['enableCustomLineHeight'] );
+               // settings.spacing.enableCustomUnits
+               $this->assertSameSets( array( 'rem' ), $settings['enableCustomUnits'] );
+               // settings.spacing.customPadding
+               $this->assertTrue( $settings['enableCustomSpacing'] );
+
+               switch_theme( WP_DEFAULT_THEME );
+       }
+
+       /**
+        * @ticket 52920
+        * @expectedDeprecated block_editor_settings
+        */
+       function test_get_block_editor_settings_deprecated_filter_post_editor() {
+               add_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ), 10, 2 );
+
+               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
+               $settings            = get_block_editor_settings( array(), $post_editor_context );
+
+               remove_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ) );
+
+               $this->assertSameSets(
+                       array(
+                               'filter' => 'deprecated',
+                       ),
+                       $settings
+               );
+       }
+
+       /**
+        * @ticket 52920
+        */
+       function test_block_editor_rest_api_preload_no_paths() {
+               $editor_context = new WP_Block_Editor_Context();
+               block_editor_rest_api_preload( array(), $editor_context );
+
+               $after = implode( '', wp_scripts()->registered['wp-api-fetch']->extra['after'] );
+               $this->assertStringNotContainsString( 'wp.apiFetch.createPreloadingMiddleware', $after );
+       }
+
+       /**
+        * @ticket 52920
+        * @expectedDeprecated block_editor_preload_paths
+        */
+       function test_block_editor_rest_api_preload_deprecated_filter_post_editor() {
+               function filter_remove_preload_paths( $preload_paths, $post ) {
+                       if ( empty( $post ) ) {
+                               return $preload_paths;
+                       }
+                       return array();
+               }
+               add_filter( 'block_editor_preload_paths', 'filter_remove_preload_paths', 10, 2 );
+
+               $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
+               block_editor_rest_api_preload(
+                       array(
+                               array( '/wp/v2/blocks', 'OPTIONS' ),
+                       ),
+                       $post_editor_context
+               );
+
+               remove_filter( 'block_editor_preload_paths', 'filter_remove_preload_paths' );
+
+               $after = implode( '', wp_scripts()->registered['wp-api-fetch']->extra['after'] );
+               $this->assertStringNotContainsString( 'wp.apiFetch.createPreloadingMiddleware', $after );
+       }
+
+       /**
+        * @ticket 52920
+        */
+       function test_block_editor_rest_api_preload_filter_all() {
+               function filter_add_preload_paths( $preload_paths, WP_Block_Editor_Context $context ) {
+                       if ( empty( $context->post ) ) {
+                               array_push( $preload_paths, array( '/wp/v2/types', 'OPTIONS' ) );
+                       }
+
+                       return $preload_paths;
+               }
+               add_filter( 'block_editor_rest_api_preload_paths', 'filter_add_preload_paths', 10, 2 );
+
+               $editor_context = new WP_Block_Editor_Context();
+               block_editor_rest_api_preload(
+                       array(
+                               array( '/wp/v2/blocks', 'OPTIONS' ),
+                       ),
+                       $editor_context
+               );
+
+               remove_filter( 'block_editor_rest_api_preload_paths', 'filter_add_preload_paths' );
+
+               $after = implode( '', wp_scripts()->registered['wp-api-fetch']->extra['after'] );
+               $this->assertStringContainsString( 'wp.apiFetch.createPreloadingMiddleware', $after );
+               $this->assertStringContainsString( '"\/wp\/v2\/blocks"', $after );
+               $this->assertStringContainsString( '"\/wp\/v2\/types"', $after );
+       }
+
+       /**
+        * @ticket 53344
+        */
+       function test_get_block_editor_theme_styles() {
+               $theme_styles = get_block_editor_theme_styles();
+               $this->assertCount( 1, $theme_styles );
+               $this->assertSameSets(
+                       array(
+                               'css'            => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }',
+                               '__unstableType' => 'core',
+                       ),
+                       $theme_styles[0]
+               );
+       }
+}
</ins></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     2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/register.php       2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,6 @@
</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">- * Block registry tests.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Block registration tests
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @package WordPress
</span><span class="cx" style="display: block; padding: 0 10px">  * @subpackage Blocks
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,13 +8,13 @@
</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">- * Tests for register_block_type(), unregister_block_type(), get_dynamic_block_names()
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Tests for register_block_type(), unregister_block_type(), get_dynamic_block_names().
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @group blocks
</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 WP_Test_Block_Register extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_Blocks_Register extends WP_UnitTestCase {
</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">         * ID for a test post.
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksrenderreusablephp"></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/blocks/render-reusable.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/render-reusable.php      2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/render-reusable.php        2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,114 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * Reusable block rendering tests.
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.0.0
- */
-
-/**
- * Tests for reusable block rendering.
- *
- * @since 5.0.0
- *
- * @group blocks
- */
-class WP_Test_Render_Reusable_Blocks extends WP_UnitTestCase {
-       /**
-        * Fake user ID.
-        *
-        * @var int
-        */
-       protected static $user_id;
-
-       /**
-        * Fake block ID.
-        *
-        * @var int
-        */
-       protected static $block_id;
-
-       /**
-        * Fake post ID.
-        *
-        * @var int
-        */
-       protected static $post_id;
-
-       /**
-        * Create fake data before tests run.
-        *
-        * @since 5.0.0
-        *
-        * @param WP_UnitTest_Factory $factory Helper that creates fake data.
-        */
-       public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
-               self::$user_id = $factory->user->create(
-                       array(
-                               'role' => 'editor',
-                       )
-               );
-
-               self::$post_id = $factory->post->create(
-                       array(
-                               'post_author'  => self::$user_id,
-                               'post_type'    => 'post',
-                               'post_status'  => 'publish',
-                               'post_title'   => 'Test Post',
-                               'post_content' => '<p>Hello world!</p>',
-                       )
-               );
-
-               self::$block_id = $factory->post->create(
-                       array(
-                               'post_author'  => self::$user_id,
-                               'post_type'    => 'wp_block',
-                               'post_status'  => 'publish',
-                               'post_title'   => 'Test Block',
-                               'post_content' => '<!-- wp:core/paragraph --><p>Hello world!</p><!-- /wp:core/paragraph -->',
-                       )
-               );
-       }
-
-       /**
-        * Delete fake data after tests run.
-        *
-        * @since 5.0.0
-        */
-       public static function wpTearDownAfterClass() {
-               wp_delete_post( self::$block_id, true );
-               wp_delete_post( self::$post_id, true );
-               self::delete_user( self::$user_id );
-       }
-
-       public function test_render() {
-               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
-               $output     = $block_type->render( array( 'ref' => self::$block_id ) );
-               $this->assertSame( '<p>Hello world!</p>', $output );
-       }
-
-       /**
-        * Make sure that a reusable block can be rendered twice in a row.
-        *
-        * @ticket 52364
-        */
-       public function test_render_subsequent() {
-               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
-               $output     = $block_type->render( array( 'ref' => self::$block_id ) );
-               $output    .= $block_type->render( array( 'ref' => self::$block_id ) );
-               $this->assertSame( '<p>Hello world!</p><p>Hello world!</p>', $output );
-       }
-
-       public function test_ref_empty() {
-               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
-               $output     = $block_type->render( array() );
-               $this->assertSame( '', $output );
-       }
-
-       public function test_ref_wrong_post_type() {
-               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
-               $output     = $block_type->render( array( 'ref' => self::$post_id ) );
-               $this->assertSame( '', $output );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksrenderphp"></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/render.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/render.php       2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/render.php 2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,6 @@
</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">- * Block rendering tests.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Block rendering tests
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @package WordPress
</span><span class="cx" style="display: block; padding: 0 10px">  * @subpackage Blocks
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,13 +8,13 @@
</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">- * Tests for block rendering functions
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Tests for block rendering functions.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @group blocks
</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 WP_Test_Block_Render extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_Blocks_Render extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * The location of the fixtures to test with.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksrenderReusablephpfromrev51490trunktestsphpunittestsblocksrenderreusablephp"></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/blocks/renderReusable.php (from rev 51490, trunk/tests/phpunit/tests/blocks/render-reusable.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/renderReusable.php                               (rev 0)
+++ trunk/tests/phpunit/tests/blocks/renderReusable.php 2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,114 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Reusable block rendering tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.0.0
+ */
+
+/**
+ * Tests for reusable block rendering.
+ *
+ * @since 5.0.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_RenderReusable extends WP_UnitTestCase {
+       /**
+        * Fake user ID.
+        *
+        * @var int
+        */
+       protected static $user_id;
+
+       /**
+        * Fake block ID.
+        *
+        * @var int
+        */
+       protected static $block_id;
+
+       /**
+        * Fake post ID.
+        *
+        * @var int
+        */
+       protected static $post_id;
+
+       /**
+        * Create fake data before tests run.
+        *
+        * @since 5.0.0
+        *
+        * @param WP_UnitTest_Factory $factory Helper that creates fake data.
+        */
+       public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+               self::$user_id = $factory->user->create(
+                       array(
+                               'role' => 'editor',
+                       )
+               );
+
+               self::$post_id = $factory->post->create(
+                       array(
+                               'post_author'  => self::$user_id,
+                               'post_type'    => 'post',
+                               'post_status'  => 'publish',
+                               'post_title'   => 'Test Post',
+                               'post_content' => '<p>Hello world!</p>',
+                       )
+               );
+
+               self::$block_id = $factory->post->create(
+                       array(
+                               'post_author'  => self::$user_id,
+                               'post_type'    => 'wp_block',
+                               'post_status'  => 'publish',
+                               'post_title'   => 'Test Block',
+                               'post_content' => '<!-- wp:core/paragraph --><p>Hello world!</p><!-- /wp:core/paragraph -->',
+                       )
+               );
+       }
+
+       /**
+        * Delete fake data after tests run.
+        *
+        * @since 5.0.0
+        */
+       public static function wpTearDownAfterClass() {
+               wp_delete_post( self::$block_id, true );
+               wp_delete_post( self::$post_id, true );
+               self::delete_user( self::$user_id );
+       }
+
+       public function test_render() {
+               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
+               $output     = $block_type->render( array( 'ref' => self::$block_id ) );
+               $this->assertSame( '<p>Hello world!</p>', $output );
+       }
+
+       /**
+        * Make sure that a reusable block can be rendered twice in a row.
+        *
+        * @ticket 52364
+        */
+       public function test_render_subsequent() {
+               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
+               $output     = $block_type->render( array( 'ref' => self::$block_id ) );
+               $output    .= $block_type->render( array( 'ref' => self::$block_id ) );
+               $this->assertSame( '<p>Hello world!</p><p>Hello world!</p>', $output );
+       }
+
+       public function test_ref_empty() {
+               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
+               $output     = $block_type->render( array() );
+               $this->assertSame( '', $output );
+       }
+
+       public function test_ref_wrong_post_type() {
+               $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
+               $output     = $block_type->render( array( 'ref' => self::$post_id ) );
+               $this->assertSame( '', $output );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblocksserializationphp"></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/blocks/serialization.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/serialization.php        2021-07-26 17:39:53 UTC (rev 51490)
+++ trunk/tests/phpunit/tests/blocks/serialization.php  2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,60 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * Block serialization tests.
- *
- * @package WordPress
- * @subpackage Blocks
- * @since 5.3.3
- */
-
-/**
- * Tests for block serialization functions
- *
- * @since 5.3.3
- *
- * @group blocks
- */
-class WP_Test_Block_Serialization extends WP_UnitTestCase {
-
-       /**
-        * @dataProvider data_serialize_identity_from_parsed
-        */
-       function test_serialize_identity_from_parsed( $original ) {
-               $blocks = parse_blocks( $original );
-
-               $actual   = serialize_blocks( $blocks );
-               $expected = $original;
-
-               $this->assertSame( $expected, $actual );
-       }
-
-       function data_serialize_identity_from_parsed() {
-               return array(
-                       // Void block.
-                       array( '<!-- wp:void /-->' ),
-
-                       // Freeform content ($block_name = null).
-                       array( 'Example.' ),
-
-                       // Block with content.
-                       array( '<!-- wp:content -->Example.<!-- /wp:content -->' ),
-
-                       // Block with attributes.
-                       array( '<!-- wp:attributes {"key":"value"} /-->' ),
-
-                       // Block with inner blocks.
-                       array( "<!-- wp:outer --><!-- wp:inner {\"key\":\"value\"} -->Example.<!-- /wp:inner -->\n\nExample.\n\n<!-- wp:void /--><!-- /wp:outer -->" ),
-
-                       // Block with attribute values that may conflict with HTML comment.
-                       array( '<!-- wp:attributes {"key":"\\u002d\\u002d\\u003c\\u003e\\u0026\\u0022"} /-->' ),
-               );
-       }
-
-       function test_serialized_block_name() {
-               $this->assertNull( strip_core_block_namespace( null ) );
-               $this->assertSame( 'example', strip_core_block_namespace( 'example' ) );
-               $this->assertSame( 'example', strip_core_block_namespace( 'core/example' ) );
-               $this->assertSame( 'plugin/example', strip_core_block_namespace( 'plugin/example' ) );
-       }
-
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsblocksserializephpfromrev51490trunktestsphpunittestsblocksserializationphp"></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/blocks/serialize.php (from rev 51490, trunk/tests/phpunit/tests/blocks/serialization.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/serialize.php                            (rev 0)
+++ trunk/tests/phpunit/tests/blocks/serialize.php      2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,60 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Block serialization tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.3.3
+ */
+
+/**
+ * Tests for block serialization functions.
+ *
+ * @since 5.3.3
+ *
+ * @group blocks
+ */
+class Tests_Blocks_Serialize extends WP_UnitTestCase {
+
+       /**
+        * @dataProvider data_serialize_identity_from_parsed
+        */
+       function test_serialize_identity_from_parsed( $original ) {
+               $blocks = parse_blocks( $original );
+
+               $actual   = serialize_blocks( $blocks );
+               $expected = $original;
+
+               $this->assertSame( $expected, $actual );
+       }
+
+       function data_serialize_identity_from_parsed() {
+               return array(
+                       // Void block.
+                       array( '<!-- wp:void /-->' ),
+
+                       // Freeform content ($block_name = null).
+                       array( 'Example.' ),
+
+                       // Block with content.
+                       array( '<!-- wp:content -->Example.<!-- /wp:content -->' ),
+
+                       // Block with attributes.
+                       array( '<!-- wp:attributes {"key":"value"} /-->' ),
+
+                       // Block with inner blocks.
+                       array( "<!-- wp:outer --><!-- wp:inner {\"key\":\"value\"} -->Example.<!-- /wp:inner -->\n\nExample.\n\n<!-- wp:void /--><!-- /wp:outer -->" ),
+
+                       // Block with attribute values that may conflict with HTML comment.
+                       array( '<!-- wp:attributes {"key":"\\u002d\\u002d\\u003c\\u003e\\u0026\\u0022"} /-->' ),
+               );
+       }
+
+       function test_serialized_block_name() {
+               $this->assertNull( strip_core_block_namespace( null ) );
+               $this->assertSame( 'example', strip_core_block_namespace( 'example' ) );
+               $this->assertSame( 'example', strip_core_block_namespace( 'core/example' ) );
+               $this->assertSame( 'plugin/example', strip_core_block_namespace( 'plugin/example' ) );
+       }
+
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblockssupportedStylesphpfromrev51490trunktestsphpunittestsblocksblocksupportedstylesphp"></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/blocks/supportedStyles.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block-supported-styles.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/supportedStyles.php                              (rev 0)
+++ trunk/tests/phpunit/tests/blocks/supportedStyles.php        2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,729 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Block supported style tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.6.0
+ */
+
+/**
+ * Test block supported styles.
+ *
+ * @since 5.6.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_SupportedStyles extends WP_UnitTestCase {
+
+       /**
+        * Block content to test with (i.e. what's wrapped by the block wrapper `<div />`).
+        *
+        * @var string
+        */
+       const BLOCK_CONTENT = '
+               <p data-image-description="&lt;p&gt;Test!&lt;/p&gt;">Test</p>
+               <p>äöü</p>
+               <p>ß</p>
+               <p>系の家庭に</p>
+               <p>Example &lt;p&gt;Test!&lt;/p&gt;</p>
+       ';
+
+       /**
+        * Registered block names.
+        *
+        * @var string[]
+        */
+       private $registered_block_names = array();
+
+       /**
+        * Tear down each test method.
+        */
+       public function tearDown() {
+               while ( ! empty( $this->registered_block_names ) ) {
+                       $block_name = array_pop( $this->registered_block_names );
+                       unregister_block_type( $block_name );
+               }
+
+               parent::tearDown();
+       }
+
+       /**
+        * Registers a block type.
+        *
+        * @param string|WP_Block_Type $name Block type name including namespace, or alternatively a
+        *                                   complete WP_Block_Type instance. In case a WP_Block_Type
+        *                                   is provided, the $args parameter will be ignored.
+        * @param array                $args {
+        *     Optional. Array of block type arguments. Any arguments may be defined, however the
+        *     ones described below are supported by default. Default empty array.
+        *
+        *     @type callable $render_callback Callback used to render blocks of this block type.
+        * }
+        */
+       protected function register_block_type( $name, $args ) {
+               register_block_type( $name, $args );
+
+               $this->registered_block_names[] = $name;
+       }
+
+       /**
+        * Retrieves attribute such as 'class' or 'style' from the rendered block string.
+        *
+        * @param string $attribute Name of attribute to get.
+        * @param string $block String of rendered block to check.
+        */
+       private function get_attribute_from_block( $attribute, $block ) {
+               $start_index = strpos( $block, $attribute . '="' ) + strlen( $attribute ) + 2;
+               $split_arr   = substr( $block, $start_index );
+               $end_index   = strpos( $split_arr, '"' );
+               return substr( $split_arr, 0, $end_index );
+       }
+
+       /**
+        * Retrieves block content from the rendered block string
+        * (i.e. what's wrapped by the block wrapper `<div />`).
+        *
+        * @param string $block String of rendered block to check.
+        */
+       private function get_content_from_block( $block ) {
+               $start_index = strpos( $block, '>' ) + 1; // First occurrence of '>'.
+               $split_arr   = substr( $block, $start_index );
+               $end_index   = strrpos( $split_arr, '<' ); // Last occurrence of '<'.
+               return substr( $split_arr, 0, $end_index ); // String between first '>' and last '<'.
+       }
+
+       /**
+        * Returns the rendered output for the current block.
+        *
+        * @param array $block Block to render.
+        * @return string Rendered output for the current block.
+        */
+       private function render_example_block( $block ) {
+               WP_Block_Supports::init();
+               WP_Block_Supports::$block_to_render = $block;
+               $wrapper_attributes                 = get_block_wrapper_attributes(
+                       array(
+                               'class' => 'foo-bar-class',
+                               'style' => 'test: style;',
+                       )
+               );
+               return '<div ' . $wrapper_attributes . '>' . self::BLOCK_CONTENT . '</div>';
+       }
+
+       /**
+        * Runs assertions that the rendered output has expected class/style attrs.
+        *
+        * @param array  $block            Block to render.
+        * @param string $expected_classes Expected output class attr string.
+        * @param string $expected_styles  Expected output styles attr string.
+        */
+       private function assert_styles_and_classes_match( $block, $expected_classes, $expected_styles ) {
+               $styled_block = $this->render_example_block( $block );
+               $class_list   = $this->get_attribute_from_block( 'class', $styled_block );
+               $style_list   = $this->get_attribute_from_block( 'style', $styled_block );
+
+               $this->assertSame( $expected_classes, $class_list, 'Class list does not match expected classes' );
+               $this->assertSame( $expected_styles, $style_list, 'Style list does not match expected styles' );
+       }
+
+       /**
+        * Runs assertions that the rendered output has expected content and class/style attrs.
+        *
+        * @param array  $block            Block to render.
+        * @param string $expected_classes Expected output class attr string.
+        * @param string $expected_styles  Expected output styles attr string.
+        */
+       private function assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles ) {
+               $styled_block = $this->render_example_block( $block );
+
+               // Ensure blocks to not add extra whitespace.
+               $this->assertSame( $styled_block, trim( $styled_block ) );
+
+               $content    = $this->get_content_from_block( $styled_block );
+               $class_list = $this->get_attribute_from_block( 'class', $styled_block );
+               $style_list = $this->get_attribute_from_block( 'style', $styled_block );
+
+               $this->assertSame( self::BLOCK_CONTENT, $content, 'Block content does not match expected content' );
+               $this->assertSameSets(
+                       explode( ' ', $expected_classes ),
+                       explode( ' ', $class_list ),
+                       'Class list does not match expected classes'
+               );
+               $this->assertSame(
+                       array_map( 'trim', explode( ';', $expected_styles ) ),
+                       array_map( 'trim', explode( ';', $style_list ) ),
+                       'Style list does not match expected styles'
+               );
+       }
+
+       /**
+        * Tests color support for named color support for named colors.
+        */
+       public function test_named_color_support() {
+               $block_type_settings = array(
+                       'attributes'      => array(),
+                       'supports'        => array(
+                               'color' => true,
+                       ),
+                       'render_callback' => true,
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'textColor'       => 'red',
+                               'backgroundColor' => 'black',
+                               // The following should not be applied (subcatagories of color support).
+                               'gradient'        => 'some-gradient',
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example has-text-color has-red-color has-background has-black-background-color';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests color support for custom colors.
+        */
+       public function test_custom_color_support() {
+               $block_type_settings = array(
+                       'attributes'      => array(),
+                       'supports'        => array(
+                               'color' => true,
+                       ),
+                       'render_callback' => true,
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'style' => array(
+                                       'color' => array(
+                                               'text'       => '#000',
+                                               'background' => '#fff',
+                                               // The following should not be applied (subcatagories of color support).
+                                               'gradient'   => 'some-gradient',
+                                               'style'      => array( 'color' => array( 'link' => '#fff' ) ),
+                                       ),
+                               ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_styles  = 'test: style; color: #000; background-color: #fff;';
+               $expected_classes = 'foo-bar-class wp-block-example has-text-color has-background';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests gradient color support for named gradients.
+        */
+       public function test_named_gradient_support() {
+               $block_type_settings = array(
+                       'attributes'      => array(),
+                       'supports'        => array(
+                               'color' => array(
+                                       'gradients' => true,
+                               ),
+                       ),
+                       'render_callback' => true,
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'gradient' => 'red',
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example has-background has-red-gradient-background';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests gradient color support for custom gradients.
+        */
+       public function test_custom_gradient_support() {
+               $block_type_settings = array(
+                       'attributes'      => array(),
+                       'supports'        => array(
+                               'color' => array(
+                                       'gradients' => true,
+                               ),
+                       ),
+                       'render_callback' => true,
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'style' => array( 'color' => array( 'gradient' => 'some-gradient-style' ) ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example has-background';
+               $expected_styles  = 'test: style; background: some-gradient-style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests that style attributes for colors are not applied without the support flag.
+        */
+       public function test_color_unsupported() {
+               $block_type_settings = array(
+                       'attributes'      => array(),
+                       'supports'        => array(),
+                       'render_callback' => true,
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'textColor'       => 'red',
+                               'backgroundColor' => 'black',
+                               'style'           => array(
+                                       'color' => array(
+                                               'text'       => '#000',
+                                               'background' => '#fff',
+                                               'link'       => '#ggg',
+                                               'gradient'   => 'some-gradient',
+                                       ),
+                               ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests support for named font sizes.
+        */
+       public function test_named_font_size() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'typography' => array(
+                                       'fontSize' => true,
+                               ),
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'fontSize' => 'large',
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example has-large-font-size';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests support for custom font sizes.
+        */
+       public function test_custom_font_size() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'typography' => array(
+                                       'fontSize' => true,
+                               ),
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'style' => array( 'typography' => array( 'fontSize' => '10px' ) ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example';
+               $expected_styles  = 'test: style; font-size: 10px;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests that font size attributes are not applied without support flag.
+        */
+       public function test_font_size_unsupported() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'fontSize' => 'large',
+                               'style'    => array( 'typography' => array( 'fontSize' => '10' ) ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests line height support.
+        */
+       public function test_line_height() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'typography' => array(
+                                       'lineHeight' => true,
+                               ),
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'style' => array( 'typography' => array( 'lineHeight' => '10' ) ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example';
+               $expected_styles  = 'test: style; line-height: 10;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests line height not applied without support flag.
+        */
+       public function test_line_height_unsupported() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'style' => array( 'typography' => array( 'lineHeight' => '10' ) ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests support for block alignment.
+        */
+       public function test_block_alignment() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'align' => true,
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'align' => 'wide',
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example alignwide';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests block alignment requires support to be added.
+        */
+       public function test_block_alignment_unsupported() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'align' => 'wide',
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example';
+               $expected_styles  = 'test: style;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests all support flags together to ensure they work together as expected.
+        */
+       public function test_all_supported() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'color'      => array(
+                                       'gradients' => true,
+                                       'link'      => true,
+                               ),
+                               'typography' => array(
+                                       'fontSize'   => true,
+                                       'lineHeight' => true,
+                               ),
+                               'align'      => true,
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'align' => 'wide',
+                               'style' => array(
+                                       'color'      => array(
+                                               'text'       => '#000',
+                                               'background' => '#fff',
+                                               'style'      => array( 'color' => array( 'link' => '#fff' ) ),
+                                       ),
+                                       'typography' => array(
+                                               'lineHeight' => '20',
+                                               'fontSize'   => '10px',
+                                       ),
+                               ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example has-text-color has-background alignwide';
+               $expected_styles  = 'test: style; color: #000; background-color: #fff; font-size: 10px; line-height: 20;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests that only styles for the supported flag are added.
+        * Verify one support enabled does not imply multiple supports enabled.
+        */
+       public function test_one_supported() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'typography' => array(
+                                       'fontSize' => true,
+                               ),
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'align' => 'wide',
+                               'style' => array(
+                                       'color'      => array(
+                                               'text'       => '#000',
+                                               'background' => '#fff',
+                                               'gradient'   => 'some-gradient',
+                                               'style'      => array( 'color' => array( 'link' => '#fff' ) ),
+                                       ),
+                                       'typography' => array(
+                                               'lineHeight' => '20',
+                                               'fontSize'   => '10px',
+                                       ),
+                               ),
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_classes = 'foo-bar-class wp-block-example';
+               $expected_styles  = 'test: style; font-size: 10px;';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests custom classname server-side block support.
+        */
+       public function test_custom_classnames_support() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'className' => 'my-custom-classname',
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_styles  = 'test: style;';
+               $expected_classes = 'foo-bar-class wp-block-example my-custom-classname';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests custom classname server-side block support opt-out.
+        */
+       public function test_custom_classnames_support_opt_out() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'customClassName' => false,
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(
+                               'className' => 'my-custom-classname',
+                       ),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_styles  = 'test: style;';
+               $expected_classes = 'foo-bar-class wp-block-example';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Tests generated classname server-side block support opt-out.
+        */
+       public function test_generated_classnames_support_opt_out() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(
+                               'className' => false,
+                       ),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               $expected_styles  = 'test: style;';
+               $expected_classes = 'foo-bar-class';
+
+               $this->assert_content_and_styles_and_classes_match( $block, $expected_classes, $expected_styles );
+       }
+
+       /**
+        * Ensures libxml_internal_errors is being used instead of @ warning suppression
+        */
+       public function test_render_block_suppresses_warnings_without_at_suppression() {
+               $block_type_settings = array(
+                       'attributes' => array(),
+                       'supports'   => array(),
+               );
+               $this->register_block_type( 'core/example', $block_type_settings );
+
+               $block = array(
+                       'blockName'    => 'core/example',
+                       'attrs'        => array(),
+                       'innerBlock'   => array(),
+                       'innerContent' => array(),
+                       'innerHTML'    => array(),
+               );
+
+               // Custom error handler's see Warnings even if they are suppressed by the @ symbol.
+               $errors = array();
+               set_error_handler(
+                       function ( $errno = 0, $errstr = '' ) use ( &$errors ) {
+                               $errors[] = $errstr;
+                               return false;
+                       }
+               );
+
+               // HTML5 elements like <time> are not supported by the DOMDocument parser used by the block supports feature.
+               // This specific example is emitted by the "Display post date" setting in the latest-posts block.
+               apply_filters( 'render_block', '<div><time datetime="2020-06-18T04:01:43+10:00" class="wp-block-latest-posts__post-date">June 18, 2020</time></div>', $block );
+
+               restore_error_handler();
+
+               $this->assertEmpty( $errors, 'Libxml errors should be dropped.' );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblockswpBlockphpfromrev51490trunktestsphpunittestsblocksblockphp"></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/blocks/wpBlock.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/wpBlock.php                              (rev 0)
+++ trunk/tests/phpunit/tests/blocks/wpBlock.php        2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,631 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WP_Block tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.5.0
+ */
+
+/**
+ * Tests for WP_Block.
+ *
+ * @since 5.5.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_wpBlock extends WP_UnitTestCase {
+
+       /**
+        * Fake block type registry.
+        *
+        * @var WP_Block_Type_Registry
+        */
+       private $registry = null;
+
+       /**
+        * Set up each test method.
+        */
+       public function setUp() {
+               parent::setUp();
+
+               $this->registry = new WP_Block_Type_Registry();
+       }
+
+       /**
+        * Tear down each test method.
+        */
+       public function tearDown() {
+               $this->registry = null;
+
+               parent::tearDown();
+       }
+
+       function filter_render_block( $content, $parsed_block ) {
+               return 'Original: "' . $content . '", from block "' . $parsed_block['blockName'] . '"';
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_constructor_assigns_properties_from_parsed_block() {
+               $this->registry->register( 'core/example', array() );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame( $parsed_block, $block->parsed_block );
+               $this->assertSame( $parsed_block['blockName'], $block->name );
+               $this->assertSame( $parsed_block['attrs'], $block->attributes );
+               $this->assertSame( $parsed_block['innerContent'], $block->inner_content );
+               $this->assertSame( $parsed_block['innerHTML'], $block->inner_html );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_constructor_assigns_block_type_from_registry() {
+               $block_type_settings = array(
+                       'attributes' => array(
+                               'defaulted' => array(
+                                       'type'    => 'number',
+                                       'default' => 10,
+                               ),
+                       ),
+               );
+               $this->registry->register( 'core/example', $block_type_settings );
+
+               $parsed_block = array( 'blockName' => 'core/example' );
+               $context      = array();
+               $block        = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertInstanceOf( WP_Block_Type::class, $block->block_type );
+               $this->assertSame(
+                       $block_type_settings['attributes'],
+                       $block->block_type->attributes
+               );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_lazily_assigns_attributes_with_defaults() {
+               $this->registry->register(
+                       'core/example',
+                       array(
+                               'attributes' => array(
+                                       'defaulted' => array(
+                                               'type'    => 'number',
+                                               'default' => 10,
+                                       ),
+                               ),
+                       )
+               );
+
+               $parsed_block = array(
+                       'blockName' => 'core/example',
+                       'attrs'     => array(
+                               'explicit' => 20,
+                       ),
+               );
+               $context      = array();
+               $block        = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame(
+                       array(
+                               'explicit'  => 20,
+                               'defaulted' => 10,
+                       ),
+                       $block->attributes
+               );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_lazily_assigns_attributes_with_only_defaults() {
+               $this->registry->register(
+                       'core/example',
+                       array(
+                               'attributes' => array(
+                                       'defaulted' => array(
+                                               'type'    => 'number',
+                                               'default' => 10,
+                                       ),
+                               ),
+                       )
+               );
+
+               $parsed_block = array(
+                       'blockName' => 'core/example',
+                       'attrs'     => array(),
+               );
+               $context      = array();
+               $block        = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame( array( 'defaulted' => 10 ), $block->attributes );
+               // Intentionally call a second time, to ensure property was assigned.
+               $this->assertSame( array( 'defaulted' => 10 ), $block->attributes );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_constructor_assigns_context_from_block_type() {
+               $this->registry->register(
+                       'core/example',
+                       array(
+                               'uses_context' => array( 'requested' ),
+                       )
+               );
+
+               $parsed_block = array( 'blockName' => 'core/example' );
+               $context      = array(
+                       'requested'   => 'included',
+                       'unrequested' => 'not included',
+               );
+               $block        = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame( array( 'requested' => 'included' ), $block->context );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_constructor_maps_inner_blocks() {
+               $this->registry->register( 'core/example', array() );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertCount( 1, $block->inner_blocks );
+               $this->assertInstanceOf( WP_Block::class, $block->inner_blocks[0] );
+               $this->assertSame( 'core/example', $block->inner_blocks[0]->name );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_constructor_prepares_context_for_inner_blocks() {
+               $this->registry->register(
+                       'core/outer',
+                       array(
+                               'attributes'       => array(
+                                       'recordId' => array(
+                                               'type' => 'number',
+                                       ),
+                               ),
+                               'provides_context' => array(
+                                       'core/recordId' => 'recordId',
+                               ),
+                       )
+               );
+               $this->registry->register(
+                       'core/inner',
+                       array(
+                               'uses_context' => array( 'core/recordId' ),
+                       )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:outer {"recordId":10} --><!-- wp:inner /--><!-- /wp:outer -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array( 'unrequested' => 'not included' );
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertCount( 0, $block->context );
+               $this->assertSame(
+                       array( 'core/recordId' => 10 ),
+                       $block->inner_blocks[0]->context
+               );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_constructor_assigns_merged_context() {
+               $this->registry->register(
+                       'core/example',
+                       array(
+                               'attributes'       => array(
+                                       'value' => array(
+                                               'type' => array( 'string', 'null' ),
+                                       ),
+                               ),
+                               'provides_context' => array(
+                                       'core/value' => 'value',
+                               ),
+                               'uses_context'     => array( 'core/value' ),
+                       )
+               );
+
+               $parsed_blocks = parse_blocks(
+                       '<!-- wp:example {"value":"merged"} -->' .
+                       '<!-- wp:example {"value":null} -->' .
+                       '<!-- wp:example /-->' .
+                       '<!-- /wp:example -->' .
+                       '<!-- /wp:example -->'
+               );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array( 'core/value' => 'original' );
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame(
+                       array( 'core/value' => 'original' ),
+                       $block->context
+               );
+               $this->assertSame(
+                       array( 'core/value' => 'merged' ),
+                       $block->inner_blocks[0]->context
+               );
+               $this->assertSame(
+                       array( 'core/value' => null ),
+                       $block->inner_blocks[0]->inner_blocks[0]->context
+               );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_render_static_block_type_returns_own_content() {
+               $this->registry->register( 'core/static', array() );
+               $this->registry->register(
+                       'core/dynamic',
+                       array(
+                               'render_callback' => function() {
+                                       return 'b';
+                               },
+                       )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:static -->a<!-- wp:dynamic /-->c<!-- /wp:static -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame( 'abc', $block->render() );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_render_passes_block_for_render_callback() {
+               $this->registry->register(
+                       'core/greeting',
+                       array(
+                               'render_callback' => function( $attributes, $content, $block ) {
+                                       return sprintf( 'Hello from %s', $block->name );
+                               },
+                       )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:greeting /-->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame( 'Hello from core/greeting', $block->render() );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_render_applies_render_block_filter() {
+               $this->registry->register( 'core/example', array() );
+
+               add_filter( 'render_block', array( $this, 'filter_render_block' ), 10, 2 );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example -->Static<!-- wp:example -->Inner<!-- /wp:example --><!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $rendered_content = $block->render();
+
+               remove_filter( 'render_block', array( $this, 'filter_render_block' ) );
+
+               $this->assertSame( 'Original: "StaticOriginal: "Inner", from block "core/example"", from block "core/example"', $rendered_content );
+       }
+
+       /**
+        * @ticket 46187
+        */
+       function test_render_applies_dynamic_render_block_filter() {
+               $this->registry->register( 'core/example', array() );
+
+               add_filter( 'render_block_core/example', array( $this, 'filter_render_block' ), 10, 2 );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example -->Static<!-- wp:example -->Inner<!-- /wp:example --><!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $rendered_content = $block->render();
+
+               remove_filter( 'render_block_core/example', array( $this, 'filter_render_block' ) );
+
+               $this->assertSame( 'Original: "StaticOriginal: "Inner", from block "core/example"", from block "core/example"', $rendered_content );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_passes_attributes_to_render_callback() {
+               $this->registry->register(
+                       'core/greeting',
+                       array(
+                               'attributes'      => array(
+                                       'toWhom'      => array(
+                                               'type' => 'string',
+                                       ),
+                                       'punctuation' => array(
+                                               'type'    => 'string',
+                                               'default' => '!',
+                                       ),
+                               ),
+                               'render_callback' => function( $block_attributes ) {
+                                       return sprintf(
+                                               'Hello %s%s',
+                                               $block_attributes['toWhom'],
+                                               $block_attributes['punctuation']
+                                       );
+                               },
+                       )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:greeting {"toWhom":"world"} /-->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame( 'Hello world!', $block->render() );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_passes_content_to_render_callback() {
+               $this->registry->register(
+                       'core/outer',
+                       array(
+                               'render_callback' => function( $block_attributes, $content ) {
+                                       return $content;
+                               },
+                       )
+               );
+               $this->registry->register(
+                       'core/inner',
+                       array(
+                               'render_callback' => function() {
+                                       return 'b';
+                               },
+                       )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:outer -->a<!-- wp:inner /-->c<!-- /wp:outer -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array();
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+
+               $this->assertSame( 'abc', $block->render() );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_build_query_vars_from_query_block() {
+               $this->registry->register(
+                       'core/example',
+                       array( 'uses_context' => array( 'query' ) )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array(
+                       'query' => array(
+                               'postType'    => 'page',
+                               'exclude'     => array( 1, 2 ),
+                               'categoryIds' => array( 56 ),
+                               'orderBy'     => 'title',
+                               'tagIds'      => array( 3, 11, 10 ),
+                       ),
+               );
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+               $query         = build_query_vars_from_query_block( $block, 1 );
+
+               $this->assertSame(
+                       $query,
+                       array(
+                               'post_type'    => 'page',
+                               'order'        => 'DESC',
+                               'orderby'      => 'title',
+                               'post__not_in' => array( 1, 2 ),
+                               'category__in' => array( 56 ),
+                               'tag__in'      => array( 3, 11, 10 ),
+                       )
+               );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_build_query_vars_from_query_block_no_context() {
+               $this->registry->register( 'core/example', array() );
+
+               $parsed_blocks    = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
+               $parsed_block     = $parsed_blocks[0];
+               $block_no_context = new WP_Block( $parsed_block, array(), $this->registry );
+               $query            = build_query_vars_from_query_block( $block_no_context, 1 );
+
+               $this->assertSame(
+                       $query,
+                       array(
+                               'post_type'    => 'post',
+                               'order'        => 'DESC',
+                               'orderby'      => 'date',
+                               'post__not_in' => array(),
+                       )
+               );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_build_query_vars_from_query_block_first_page() {
+               $this->registry->register(
+                       'core/example',
+                       array( 'uses_context' => array( 'query' ) )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array(
+                       'query' => array(
+                               'perPage' => 2,
+                               'offset'  => 0,
+                       ),
+               );
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+               $query         = build_query_vars_from_query_block( $block, 1 );
+
+               $this->assertSame(
+                       $query,
+                       array(
+                               'post_type'      => 'post',
+                               'order'          => 'DESC',
+                               'orderby'        => 'date',
+                               'post__not_in'   => array(),
+                               'offset'         => 0,
+                               'posts_per_page' => 2,
+                       )
+               );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_build_query_vars_from_query_block_page_no_offset() {
+               $this->registry->register(
+                       'core/example',
+                       array( 'uses_context' => array( 'query' ) )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array(
+                       'query' => array(
+                               'perPage' => 5,
+                               'offset'  => 0,
+                       ),
+               );
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+               $query         = build_query_vars_from_query_block( $block, 3 );
+               $this->assertSame(
+                       $query,
+                       array(
+                               'post_type'      => 'post',
+                               'order'          => 'DESC',
+                               'orderby'        => 'date',
+                               'post__not_in'   => array(),
+                               'offset'         => 10,
+                               'posts_per_page' => 5,
+                       )
+               );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_build_query_vars_from_query_block_page_with_offset() {
+               $this->registry->register(
+                       'core/example',
+                       array( 'uses_context' => array( 'query' ) )
+               );
+
+               $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' );
+               $parsed_block  = $parsed_blocks[0];
+               $context       = array(
+                       'query' => array(
+                               'perPage' => 5,
+                               'offset'  => 2,
+                       ),
+               );
+               $block         = new WP_Block( $parsed_block, $context, $this->registry );
+               $query         = build_query_vars_from_query_block( $block, 3 );
+               $this->assertSame(
+                       $query,
+                       array(
+                               'post_type'      => 'post',
+                               'order'          => 'DESC',
+                               'orderby'        => 'date',
+                               'post__not_in'   => array(),
+                               'offset'         => 12,
+                               'posts_per_page' => 5,
+                       )
+               );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_block_has_support() {
+               $this->registry->register(
+                       'core/example',
+                       array(
+                               'supports' => array(
+                                       'align'    => array( 'wide', 'full' ),
+                                       'fontSize' => true,
+                                       'color'    => array(
+                                               'link'     => true,
+                                               'gradient' => false,
+                                       ),
+                               ),
+                       )
+               );
+               $block_type    = $this->registry->get_registered( 'core/example' );
+               $align_support = block_has_support( $block_type, array( 'align' ) );
+               $this->assertTrue( $align_support );
+               $gradient_support = block_has_support( $block_type, array( 'color', 'gradient' ) );
+               $this->assertFalse( $gradient_support );
+               $link_support = block_has_support( $block_type, array( 'color', 'link' ), false );
+               $this->assertTrue( $link_support );
+               $text_support = block_has_support( $block_type, array( 'color', 'text' ) );
+               $this->assertFalse( $text_support );
+               $font_nested = block_has_support( $block_type, array( 'fontSize', 'nested' ) );
+               $this->assertFalse( $font_nested );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_block_has_support_no_supports() {
+               $this->registry->register( 'core/example', array() );
+               $block_type  = $this->registry->get_registered( 'core/example' );
+               $has_support = block_has_support( $block_type, array( 'color' ) );
+               $this->assertFalse( $has_support );
+       }
+
+       /**
+        * @ticket 52991
+        */
+       public function test_block_has_support_provided_defaults() {
+               $this->registry->register(
+                       'core/example',
+                       array(
+                               'supports' => array(
+                                       'color' => array(
+                                               'gradient' => false,
+                                       ),
+                               ),
+                       )
+               );
+               $block_type    = $this->registry->get_registered( 'core/example' );
+               $align_support = block_has_support( $block_type, array( 'align' ), true );
+               $this->assertTrue( $align_support );
+               $gradient_support = block_has_support( $block_type, array( 'color', 'gradient' ), true );
+               $this->assertFalse( $gradient_support );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblockswpBlockListphpfromrev51490trunktestsphpunittestsblocksblocklistphp"></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/blocks/wpBlockList.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block-list.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/wpBlockList.php                          (rev 0)
+++ trunk/tests/phpunit/tests/blocks/wpBlockList.php    2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,112 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WP_Block_List tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.5.0
+ */
+
+/**
+ * Tests for WP_Block_List.
+ *
+ * @since 5.5.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_wpBlockList extends WP_UnitTestCase {
+
+       /**
+        * Fake block type registry.
+        *
+        * @var WP_Block_Type_Registry
+        */
+       private $registry = null;
+
+       /**
+        * Set up each test method.
+        */
+       public function setUp() {
+               parent::setUp();
+
+               $this->registry = new WP_Block_Type_Registry();
+               $this->registry->register( 'core/example', array() );
+       }
+
+       /**
+        * Tear down each test method.
+        */
+       public function tearDown() {
+               $this->registry = null;
+
+               parent::tearDown();
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_array_access() {
+               $parsed_blocks = parse_blocks( '<!-- wp:example /-->' );
+               $context       = array();
+               $blocks        = new WP_Block_List( $parsed_blocks, $context, $this->registry );
+
+               // Test "offsetExists".
+               $this->assertArrayHasKey( 0, $blocks );
+
+               // Test "offsetGet".
+               $this->assertSame( 'core/example', $blocks[0]->name );
+
+               // Test "offsetSet".
+               $parsed_blocks[0]['blockName'] = 'core/updated';
+               $blocks[0]                     = new WP_Block( $parsed_blocks[0], $context, $this->registry );
+               $this->assertSame( 'core/updated', $blocks[0]->name );
+
+               // Test "offsetUnset".
+               unset( $blocks[0] );
+               $this->assertArrayNotHasKey( 0, $blocks );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_iterable() {
+               $parsed_blocks = parse_blocks( '<!-- wp:example --><!-- wp:example /--><!-- /wp:example -->' );
+               $context       = array();
+               $blocks        = new WP_Block_List( $parsed_blocks, $context, $this->registry );
+               $assertions    = 0;
+
+               foreach ( $blocks as $block ) {
+                       $this->assertSame( 'core/example', $block->name );
+                       $assertions++;
+                       foreach ( $block->inner_blocks as $inner_block ) {
+                               $this->assertSame( 'core/example', $inner_block->name );
+                               $assertions++;
+                       }
+               }
+
+               $blocks->rewind();
+               while ( $blocks->valid() ) {
+                       $key   = $blocks->key();
+                       $block = $blocks->current();
+                       $this->assertSame( 0, $key );
+                       $assertions++;
+                       $this->assertSame( 'core/example', $block->name );
+                       $assertions++;
+                       $blocks->next();
+               }
+
+               $this->assertSame( 4, $assertions );
+       }
+
+       /**
+        * @ticket 49927
+        */
+       function test_countable() {
+               $parsed_blocks = parse_blocks( '<!-- wp:example /-->' );
+               $context       = array();
+               $blocks        = new WP_Block_List( $parsed_blocks, $context, $this->registry );
+
+               $this->assertCount( 1, $blocks );
+       }
+
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblockswpBlockParserphpfromrev51490trunktestsphpunittestsblocksblockparserphp"></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/blocks/wpBlockParser.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block-parser.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/wpBlockParser.php                                (rev 0)
+++ trunk/tests/phpunit/tests/blocks/wpBlockParser.php  2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,119 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WP_Block_Parser tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.0.0
+ */
+
+/**
+ * Tests for WP_Block_Parser.
+ *
+ * @since 5.0.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_wpBlockParser extends WP_UnitTestCase {
+       /**
+        * The location of the fixtures to test with.
+        *
+        * @since 5.0.0
+        * @var string
+        */
+       protected static $fixtures_dir;
+
+       /**
+        * @ticket 45109
+        */
+       public function data_parsing_test_filenames() {
+               self::$fixtures_dir = DIR_TESTDATA . '/blocks/fixtures';
+
+               $fixture_filenames = array_merge(
+                       glob( self::$fixtures_dir . '/*.json' ),
+                       glob( self::$fixtures_dir . '/*.html' )
+               );
+
+               $fixture_filenames = array_values(
+                       array_unique(
+                               array_map(
+                                       array( $this, 'clean_fixture_filename' ),
+                                       $fixture_filenames
+                               )
+                       )
+               );
+
+               return array_map(
+                       array( $this, 'pass_parser_fixture_filenames' ),
+                       $fixture_filenames
+               );
+       }
+
+       /**
+        * @dataProvider data_parsing_test_filenames
+        * @ticket 45109
+        */
+       public function test_default_parser_output( $html_filename, $parsed_json_filename ) {
+               $html_path        = self::$fixtures_dir . '/' . $html_filename;
+               $parsed_json_path = self::$fixtures_dir . '/' . $parsed_json_filename;
+
+               foreach ( array( $html_path, $parsed_json_path ) as $filename ) {
+                       if ( ! file_exists( $filename ) ) {
+                               throw new Exception( "Missing fixture file: '$filename'" );
+                       }
+               }
+
+               $html            = self::strip_r( file_get_contents( $html_path ) );
+               $expected_parsed = json_decode( self::strip_r( file_get_contents( $parsed_json_path ) ), true );
+
+               $parser = new WP_Block_Parser();
+               $result = json_decode( json_encode( $parser->parse( $html ) ), true );
+
+               $this->assertSame(
+                       $expected_parsed,
+                       $result,
+                       "File '$parsed_json_filename' does not match expected value"
+               );
+       }
+
+       /**
+        * Helper function to remove relative paths and extension from a filename, leaving just the fixture name.
+        *
+        * @since 5.0.0
+        *
+        * @param string $filename The filename to clean.
+        * @return string The cleaned fixture name.
+        */
+       protected function clean_fixture_filename( $filename ) {
+               $filename = wp_basename( $filename );
+               $filename = preg_replace( '/\..+$/', '', $filename );
+               return $filename;
+       }
+
+       /**
+        * Helper function to return the filenames needed to test the parser output.
+        *
+        * @since 5.0.0
+        *
+        * @param string $filename The cleaned fixture name.
+        * @return array The input and expected output filenames for that fixture.
+        */
+       protected function pass_parser_fixture_filenames( $filename ) {
+               return array(
+                       "$filename.html",
+                       "$filename.parsed.json",
+               );
+       }
+
+       /**
+        * Helper function to remove '\r' characters from a string.
+        *
+        * @since 5.0.0
+        *
+        * @param string $input The string to remove '\r' from.
+        * @return string The input string, with '\r' characters removed.
+        */
+       protected function strip_r( $input ) {
+               return str_replace( "\r", '', $input );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblockswpBlockTypephpfromrev51490trunktestsphpunittestsblocksblocktypephp"></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/blocks/wpBlockType.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block-type.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/wpBlockType.php                          (rev 0)
+++ trunk/tests/phpunit/tests/blocks/wpBlockType.php    2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,422 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WP_Block_Type tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.0.0
+ */
+
+/**
+ * Tests for WP_Block_Type.
+ *
+ * @since 5.0.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_wpBlockType extends WP_UnitTestCase {
+
+       /**
+        * Editor user ID.
+        *
+        * @since 5.0.0
+        * @var int
+        */
+       protected static $editor_user_id;
+
+       /**
+        * ID for a post containing blocks.
+        *
+        * @since 5.0.0
+        * @var int
+        */
+       protected static $post_with_blocks;
+
+       /**
+        * ID for a post without blocks.
+        *
+        * @since 5.0.0
+        * @var int
+        */
+       protected static $post_without_blocks;
+
+       /**
+        * Set up before class.
+        *
+        * @since 5.0.0
+        */
+       public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+               self::$editor_user_id = $factory->user->create(
+                       array(
+                               'role' => 'editor',
+                       )
+               );
+
+               self::$post_with_blocks = $factory->post->create(
+                       array(
+                               'post_title'   => 'Example',
+                               'post_content' => "<!-- wp:core/text {\"dropCap\":true} -->\n<p class=\"has-drop-cap\">Tester</p>\n<!-- /wp:core/text -->",
+                       )
+               );
+
+               self::$post_without_blocks = $factory->post->create(
+                       array(
+                               'post_title'   => 'Example',
+                               'post_content' => 'Tester',
+                       )
+               );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_set_props() {
+               $name = 'core/fake';
+               $args = array(
+                       'render_callback' => array( $this, 'render_fake_block' ),
+                       'foo'             => 'bar',
+               );
+
+               $block_type = new WP_Block_Type( $name, $args );
+
+               $this->assertSame( $name, $block_type->name );
+               $this->assertSame( $args['render_callback'], $block_type->render_callback );
+               $this->assertSame( $args['foo'], $block_type->foo );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_render() {
+               $attributes = array(
+                       'foo' => 'bar',
+                       'bar' => 'foo',
+               );
+
+               $block_type = new WP_Block_Type(
+                       'core/fake',
+                       array(
+                               'render_callback' => array( $this, 'render_fake_block' ),
+                       )
+               );
+               $output     = $block_type->render( $attributes );
+               $this->assertSame( $attributes, json_decode( $output, true ) );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_render_with_content() {
+               $attributes = array(
+                       'foo' => 'bar',
+                       'bar' => 'foo',
+               );
+
+               $content = 'baz';
+
+               $expected = array_merge( $attributes, array( '_content' => $content ) );
+
+               $block_type = new WP_Block_Type(
+                       'core/fake',
+                       array(
+                               'render_callback' => array( $this, 'render_fake_block_with_content' ),
+                       )
+               );
+               $output     = $block_type->render( $attributes, $content );
+               $this->assertSame( $expected, json_decode( $output, true ) );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_render_for_static_block() {
+               $block_type = new WP_Block_Type( 'core/fake', array() );
+               $output     = $block_type->render();
+
+               $this->assertSame( '', $output );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_is_dynamic_for_static_block() {
+               $block_type = new WP_Block_Type( 'core/fake', array() );
+
+               $this->assertFalse( $block_type->is_dynamic() );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_is_dynamic_for_dynamic_block() {
+               $block_type = new WP_Block_Type(
+                       'core/fake',
+                       array(
+                               'render_callback' => array( $this, 'render_fake_block' ),
+                       )
+               );
+
+               $this->assertTrue( $block_type->is_dynamic() );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_prepare_attributes() {
+               $attributes = array(
+                       'correct'            => 'include',
+                       'wrongType'          => 5,
+                       'wrongTypeDefaulted' => 5,
+                       /* missingDefaulted */
+                       'undefined'          => 'include',
+                       'intendedNull'       => null,
+               );
+
+               $block_type = new WP_Block_Type(
+                       'core/fake',
+                       array(
+                               'attributes' => array(
+                                       'correct'            => array(
+                                               'type' => 'string',
+                                       ),
+                                       'wrongType'          => array(
+                                               'type' => 'string',
+                                       ),
+                                       'wrongTypeDefaulted' => array(
+                                               'type'    => 'string',
+                                               'default' => 'defaulted',
+                                       ),
+                                       'missingDefaulted'   => array(
+                                               'type'    => 'string',
+                                               'default' => 'define',
+                                       ),
+                                       'intendedNull'       => array(
+                                               'type'    => array( 'string', 'null' ),
+                                               'default' => 'wrong',
+                                       ),
+                               ),
+                       )
+               );
+
+               $prepared_attributes = $block_type->prepare_attributes_for_render( $attributes );
+
+               $this->assertEquals(
+                       array(
+                               'correct'            => 'include',
+                               /* wrongType */
+                               'wrongTypeDefaulted' => 'defaulted',
+                               'missingDefaulted'   => 'define',
+                               'undefined'          => 'include',
+                               'intendedNull'       => null,
+                       ),
+                       $prepared_attributes
+               );
+       }
+
+       /**
+        * @ticket 45145
+        */
+       function test_prepare_attributes_none_defined() {
+               $attributes = array( 'exists' => 'keep' );
+
+               $block_type = new WP_Block_Type( 'core/dummy', array() );
+
+               $prepared_attributes = $block_type->prepare_attributes_for_render( $attributes );
+
+               $this->assertSame( $attributes, $prepared_attributes );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_has_block_with_mixed_content() {
+               $mixed_post_content = 'before' .
+               '<!-- wp:core/fake --><!-- /wp:core/fake -->' .
+               '<!-- wp:core/fake_atts {"value":"b1"} --><!-- /wp:core/fake_atts -->' .
+               '<!-- wp:core/fake-child -->
+               <p>testing the test</p>
+               <!-- /wp:core/fake-child -->' .
+               'between' .
+               '<!-- wp:core/self-close-fake /-->' .
+               '<!-- wp:custom/fake {"value":"b2"} /-->' .
+               'after';
+
+               $this->assertTrue( has_block( 'core/fake', $mixed_post_content ) );
+
+               $this->assertTrue( has_block( 'core/fake_atts', $mixed_post_content ) );
+
+               $this->assertTrue( has_block( 'core/fake-child', $mixed_post_content ) );
+
+               $this->assertTrue( has_block( 'core/self-close-fake', $mixed_post_content ) );
+
+               $this->assertTrue( has_block( 'custom/fake', $mixed_post_content ) );
+
+               // checking for a partial block name should fail.
+               $this->assertFalse( has_block( 'core/fak', $mixed_post_content ) );
+
+               // checking for a wrong namespace should fail.
+               $this->assertFalse( has_block( 'custom/fake_atts', $mixed_post_content ) );
+
+               // checking for namespace only should not work. Or maybe ... ?
+               $this->assertFalse( has_block( 'core', $mixed_post_content ) );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_has_block_with_invalid_content() {
+               // some content with invalid HMTL comments and a single valid block.
+               $invalid_content = 'before' .
+               '<!- - wp:core/weird-space --><!-- /wp:core/weird-space -->' .
+               '<!--wp:core/untrimmed-left --><!-- /wp:core/untrimmed -->' .
+               '<!-- wp:core/fake --><!-- /wp:core/fake -->' .
+               '<!-- wp:core/untrimmed-right--><!-- /wp:core/untrimmed2 -->' .
+               'after';
+
+               $this->assertFalse( has_block( 'core/text', self::$post_without_blocks ) );
+
+               $this->assertFalse( has_block( 'core/weird-space', $invalid_content ) );
+
+               $this->assertFalse( has_block( 'core/untrimmed-left', $invalid_content ) );
+
+               $this->assertFalse( has_block( 'core/untrimmed-right', $invalid_content ) );
+
+               $this->assertTrue( has_block( 'core/fake', $invalid_content ) );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_post_has_block() {
+               // should fail for a non-existent block `custom/fake`.
+               $this->assertFalse( has_block( 'custom/fake', self::$post_with_blocks ) );
+
+               // this functions should not work without the second param until the $post global is set.
+               $this->assertFalse( has_block( 'core/text' ) );
+               $this->assertFalse( has_block( 'core/fake' ) );
+
+               global $post;
+               $post = get_post( self::$post_with_blocks );
+
+               // check if the function correctly detects content from the $post global.
+               $this->assertTrue( has_block( 'core/text' ) );
+               // even if it detects a proper $post global it should still be false for a missing block.
+               $this->assertFalse( has_block( 'core/fake' ) );
+       }
+
+       public function test_post_has_block_serialized_name() {
+               $content = '<!-- wp:serialized /--><!-- wp:core/normalized /--><!-- wp:plugin/third-party /-->';
+
+               $this->assertTrue( has_block( 'core/serialized', $content ) );
+
+               /*
+                * Technically, `has_block` should receive a "full" (normalized, parsed)
+                * block name. But this test conforms to expected pre-5.3.1 behavior.
+                */
+               $this->assertTrue( has_block( 'serialized', $content ) );
+               $this->assertTrue( has_block( 'core/normalized', $content ) );
+               $this->assertTrue( has_block( 'normalized', $content ) );
+               $this->assertFalse( has_block( 'plugin/normalized', $content ) );
+               $this->assertFalse( has_block( 'plugin/serialized', $content ) );
+               $this->assertFalse( has_block( 'third-party', $content ) );
+               $this->assertFalse( has_block( 'core/third-party', $content ) );
+       }
+
+       /**
+        * Renders a test block without content.
+        *
+        * @since 5.0.0
+        *
+        * @param array $attributes Block attributes. Default empty array.
+        * @return string JSON encoded list of attributes.
+        */
+       public function render_fake_block( $attributes ) {
+               return json_encode( $attributes );
+       }
+
+       /**
+        * Renders a test block with content.
+        *
+        * @since 5.0.0
+        *
+        * @param array  $attributes Block attributes. Default empty array.
+        * @param string $content    Block content. Default empty string.
+        * @return string JSON encoded list of attributes.
+        */
+       public function render_fake_block_with_content( $attributes, $content ) {
+               $attributes['_content'] = $content;
+
+               return json_encode( $attributes );
+       }
+
+       /**
+        * @ticket 48529
+        */
+       public function test_register_block() {
+               $block_type = new WP_Block_Type(
+                       'core/fake',
+                       array(
+                               'title'       => 'Test title',
+                               'category'    => 'Test category',
+                               'parent'      => array( 'core/third-party' ),
+                               'icon'        => 'icon.png',
+                               'description' => 'test description',
+                               'keywords'    => array( 'test keyword' ),
+                               'textdomain'  => 'test_domain',
+                               'supports'    => array( 'alignment' => true ),
+                       )
+               );
+
+               $this->assertSame( 'Test title', $block_type->title );
+               $this->assertSame( 'Test category', $block_type->category );
+               $this->assertSameSets( array( 'core/third-party' ), $block_type->parent );
+               $this->assertSame( 'icon.png', $block_type->icon );
+               $this->assertSame( 'test description', $block_type->description );
+               $this->assertSameSets( array( 'test keyword' ), $block_type->keywords );
+               $this->assertSame( 'test_domain', $block_type->textdomain );
+               $this->assertSameSets( array( 'alignment' => true ), $block_type->supports );
+       }
+
+       /**
+        * Testing the block version.
+        *
+        * @ticket 43887
+        *
+        * @dataProvider data_block_version
+        *
+        * @param string|null $content  Content.
+        * @param int         $expected Expected block version.
+        */
+       public function test_block_version( $content, $expected ) {
+               $this->assertSame( $expected, block_version( $content ) );
+       }
+
+       /**
+        * Test cases for test_block_version().
+        *
+        * @since 5.0.0
+        *
+        * @return array {
+        *     @type array {
+        *         @type string|null Content.
+        *         @type int         Expected block version.
+        *     }
+        * }
+        */
+       public function data_block_version() {
+               return array(
+                       // Null.
+                       array( null, 0 ),
+                       // Empty post content.
+                       array( '', 0 ),
+                       // Post content without blocks.
+                       array( '<hr class="wp-block-separator" />', 0 ),
+                       // Post content with a block.
+                       array( '<!-- wp:core/separator -->', 1 ),
+                       // Post content with a fake block.
+                       array( '<!-- wp:core/fake --><!-- /wp:core/fake -->', 1 ),
+                       // Post content with an invalid block.
+                       array( '<!- - wp:core/separator -->', 0 ),
+               );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsblockswpBlockTypeRegistryphpfromrev51490trunktestsphpunittestsblocksblocktyperegistryphp"></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/blocks/wpBlockTypeRegistry.php (from rev 51490, trunk/tests/phpunit/tests/blocks/block-type-registry.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/wpBlockTypeRegistry.php                          (rev 0)
+++ trunk/tests/phpunit/tests/blocks/wpBlockTypeRegistry.php    2021-07-26 18:45:48 UTC (rev 51491)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,191 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WP_Block_Type_Registry tests
+ *
+ * @package WordPress
+ * @subpackage Blocks
+ * @since 5.0.0
+ */
+
+/**
+ * Tests for WP_Block_Type_Registry.
+ *
+ * @since 5.0.0
+ *
+ * @group blocks
+ */
+class Tests_Blocks_wpBlockTypeRegistry extends WP_UnitTestCase {
+
+       /**
+        * Fake block type registry.
+        *
+        * @since 5.0.0
+        * @var WP_Block_Type_Registry
+        */
+       private $registry = null;
+
+       /**
+        * Set up each test method.
+        *
+        * @since 5.0.0
+        */
+       public function setUp() {
+               parent::setUp();
+
+               $this->registry = new WP_Block_Type_Registry();
+       }
+
+       /**
+        * Tear down each test method.
+        *
+        * @since 5.0.0
+        */
+       public function tearDown() {
+               $this->registry = null;
+
+               parent::tearDown();
+       }
+
+       /**
+        * Should reject numbers
+        *
+        * @ticket 45097
+        *
+        * @expectedIncorrectUsage WP_Block_Type_Registry::register
+        */
+       public function test_invalid_non_string_names() {
+               $result = $this->registry->register( 1, array() );
+               $this->assertFalse( $result );
+       }
+
+       /**
+        * Should reject blocks without a namespace
+        *
+        * @ticket 45097
+        *
+        * @expectedIncorrectUsage WP_Block_Type_Registry::register
+        */
+       public function test_invalid_names_without_namespace() {
+               $result = $this->registry->register( 'paragraph', array() );
+               $this->assertFalse( $result );
+       }
+
+       /**
+        * Should reject blocks with invalid characters
+        *
+        * @ticket 45097
+        *
+        * @expectedIncorrectUsage WP_Block_Type_Registry::register
+        */
+       public function test_invalid_characters() {
+               $result = $this->registry->register( 'still/_doing_it_wrong', array() );
+               $this->assertFalse( $result );
+       }
+
+       /**
+        * Should reject blocks with uppercase characters
+        *
+        * @ticket 45097
+        *
+        * @expectedIncorrectUsage WP_Block_Type_Registry::register
+        */
+       public function test_uppercase_characters() {
+               $result = $this->registry->register( 'Core/Paragraph', array() );
+               $this->assertFalse( $result );
+       }
+
+       /**
+        * Should accept valid block names
+        *
+        * @ticket 45097
+        */
+       public function test_register_block_type() {
+               $name     = 'core/paragraph';
+               $settings = array(
+                       'icon' => 'editor-paragraph',
+               );
+
+               $block_type = $this->registry->register( $name, $settings );
+               $this->assertSame( $name, $block_type->name );
+               $this->assertSame( $settings['icon'], $block_type->icon );
+               $this->assertSame( $block_type, $this->registry->get_registered( $name ) );
+       }
+
+       /**
+        * Should fail to re-register the same block
+        *
+        * @ticket 45097
+        *
+        * @expectedIncorrectUsage WP_Block_Type_Registry::register
+        */
+       public function test_register_block_type_twice() {
+               $name     = 'core/paragraph';
+               $settings = array(
+                       'icon' => 'editor-paragraph',
+               );
+
+               $result = $this->registry->register( $name, $settings );
+               $this->assertNotFalse( $result );
+               $result = $this->registry->register( $name, $settings );
+               $this->assertFalse( $result );
+       }
+
+       /**
+        * Should accept a WP_Block_Type instance
+        *
+        * @ticket 45097
+        */
+       public function test_register_block_type_instance() {
+               $block_type = new WP_Fake_Block_Type( 'core/fake' );
+
+               $result = $this->registry->register( $block_type );
+               $this->assertSame( $block_type, $result );
+       }
+
+       /**
+        * Unregistering should fail if a block is not registered
+        *
+        * @ticket 45097
+        *
+        * @expectedIncorrectUsage WP_Block_Type_Registry::unregister
+        */
+       public function test_unregister_not_registered_block() {
+               $result = $this->registry->unregister( 'core/unregistered' );
+               $this->assertFalse( $result );
+       }
+
+       /**
+        * Should unregister existing blocks
+        *
+        * @ticket 45097
+        */
+       public function test_unregister_block_type() {
+               $name     = 'core/paragraph';
+               $settings = array(
+                       'icon' => 'editor-paragraph',
+               );
+
+               $this->registry->register( $name, $settings );
+               $block_type = $this->registry->unregister( $name );
+               $this->assertSame( $name, $block_type->name );
+               $this->assertSame( $settings['icon'], $block_type->icon );
+               $this->assertFalse( $this->registry->is_registered( $name ) );
+       }
+
+       /**
+        * @ticket 45097
+        */
+       public function test_get_all_registered() {
+               $names    = array( 'core/paragraph', 'core/image', 'core/blockquote' );
+               $settings = array(
+                       'icon' => 'random',
+               );
+
+               foreach ( $names as $name ) {
+                       $this->registry->register( $name, $settings );
+               }
+
+               $registered = $this->registry->get_all_registered();
+               $this->assertSameSets( $names, array_keys( $registered ) );
+       }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>