<!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>[54382] trunk/tests/phpunit/tests: Editor: Add PHPUnit tests for 5.9.0 new functions.</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/54382">54382</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/54382","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>hellofromTonya</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-10-04 14:20:18 +0000 (Tue, 04 Oct 2022)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor: Add PHPUnit tests for 5.9.0 new functions.

During the 5.9.0 cycle, tests were missed during the porting from Gutenberg to Core for the following functions:

* `_disable_block_editor_for_navigation_post_type()`
* `_disable_content_editor_for_navigation_post_type()`
* `_enable_content_editor_for_navigation_post_type()`
* `wp_filter_global_styles_post()`

This commit adds new test classes for these functions.

Reference:
* [https://github.com/WordPress/gutenberg/blob/release/13.6/phpunit/global-styles-test.php Gutenberg v13.6] for `WP_Global_Styles_Test`
* [https://github.com/WordPress/gutenberg/blob/release/13.6/phpunit/navigation-test.php Gutenberg v13.6] for `WP_Navigation_Test`

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

Props antonvlasenko, costdev, ironprogrammer, robinwpdeveloper, hellofromTonya.
Fixes <a href="https://core.trac.wordpress.org/ticket/56266">#56266</a>.</pre>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestseditordisableBlockEditorForNavigationPostTypephp">trunk/tests/phpunit/tests/editor/disableBlockEditorForNavigationPostType.php</a></li>
<li><a href="#trunktestsphpunittestseditordisableContentEditorForNavigationPostTypephp">trunk/tests/phpunit/tests/editor/disableContentEditorForNavigationPostType.php</a></li>
<li><a href="#trunktestsphpunittestseditorenableContentEditorForNavigationPostTypephp">trunk/tests/phpunit/tests/editor/enableContentEditorForNavigationPostType.php</a></li>
<li>trunk/tests/phpunit/tests/kses/</li>
<li><a href="#trunktestsphpunittestskseswpFilterGlobalStylesPostphp">trunk/tests/phpunit/tests/kses/wpFilterGlobalStylesPost.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestseditordisableBlockEditorForNavigationPostTypephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/editor/disableBlockEditorForNavigationPostType.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/editor/disableBlockEditorForNavigationPostType.php                              (rev 0)
+++ trunk/tests/phpunit/tests/editor/disableBlockEditorForNavigationPostType.php        2022-10-04 14:20:18 UTC (rev 54382)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,105 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * @group editor
+ *
+ * @covers ::_disable_block_editor_for_navigation_post_type
+ */
+class Tests_Editor_DisableBlockEditorForNavigationPostType extends WP_UnitTestCase {
+       const NAVIGATION_POST_TYPE = 'wp_navigation';
+
+       /**
+        * @dataProvider data_should_return_false_when_wp_navigation
+        * @ticket       56266
+        *
+        * @param bool $supports Whether the CPT supports block editor or not.
+        */
+       public function test_should_return_false_when_wp_navigation( $supports ) {
+               $this->assertFalse( _disable_block_editor_for_navigation_post_type( $supports, static::NAVIGATION_POST_TYPE ) );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array
+        */
+       public function data_should_return_false_when_wp_navigation() {
+               return array(
+                       'support value: true'  => array( true ),
+                       'support value: false' => array( false ),
+               );
+       }
+
+       /**
+        * @dataProvider data_should_return_given_value_for_non_wp_navigation_post_types
+        * @ticket       56266
+        *
+        * @param bool   $supports  Whether the CPT supports block editor or not.
+        * @param string $post_type The post type
+        */
+       public function test_should_return_given_value_for_non_wp_navigation_post_types( $supports, $post_type ) {
+               $this->assertSame( $supports, _disable_block_editor_for_navigation_post_type( $supports, $post_type ) );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array
+        */
+       public function data_should_return_given_value_for_non_wp_navigation_post_types() {
+               return array(
+                       'post'                => array(
+                               'post_type' => 'post',
+                               'supports'  => true,
+                       ),
+                       'page'                => array(
+                               'post_type' => 'page',
+                               'supports'  => true,
+                       ),
+                       'attachments'         => array(
+                               'post_type' => 'attachments',
+                               'supports'  => false,
+                       ),
+                       'revision'            => array(
+                               'post_type' => 'revision',
+                               'supports'  => false,
+                       ),
+                       'custom_css'          => array(
+                               'post_type' => 'custom_css',
+                               'supports'  => false,
+                       ),
+                       'customize_changeset' => array(
+                               'post_type' => 'customize_changeset',
+                               'supports'  => false,
+                       ),
+                       'nav_menu_item'       => array(
+                               'post_type' => 'nav_menu_item',
+                               'supports'  => true,
+                       ),
+                       'oembed_cache'        => array(
+                               'post_type' => 'oembed_cache',
+                               'supports'  => true,
+                       ),
+                       'user_request'        => array(
+                               'post_type' => 'user_request',
+                               'supports'  => true,
+                       ),
+                       'wp_block'            => array(
+                               'post_type' => 'wp_block',
+                               'supports'  => true,
+                       ),
+                       'wp_template'         => array(
+                               'post_type' => 'wp_template',
+                               'supports'  => true,
+                       ),
+                       'wp_template_part'    => array(
+                               'post_type' => 'wp_template_part',
+                               'supports'  => true,
+                       ),
+                       'wp_global_styles'    => array(
+                               'post_type' => 'wp_global_styles',
+                               'supports'  => true,
+                       ),
+               );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/editor/disableBlockEditorForNavigationPostType.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestseditordisableContentEditorForNavigationPostTypephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/editor/disableContentEditorForNavigationPostType.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/editor/disableContentEditorForNavigationPostType.php                            (rev 0)
+++ trunk/tests/phpunit/tests/editor/disableContentEditorForNavigationPostType.php      2022-10-04 14:20:18 UTC (rev 54382)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,113 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group editor
+ *
+ * @covers ::_disable_content_editor_for_navigation_post_type
+ */
+class Tests_Editor_DisableContentEditorForNavigationPostType extends WP_UnitTestCase {
+       const NAVIGATION_POST_TYPE = 'wp_navigation';
+
+       public function tear_down() {
+               add_post_type_support( static::NAVIGATION_POST_TYPE, 'editor' );
+               parent::tear_down();
+       }
+
+       /**
+        * @ticket 56266
+        */
+       public function test_should_disable() {
+               $post = $this->create_post( static::NAVIGATION_POST_TYPE );
+
+               $this->assertTrue( post_type_supports( static::NAVIGATION_POST_TYPE, 'editor' ) );
+
+               _disable_content_editor_for_navigation_post_type( $post );
+
+               $this->assertFalse( post_type_supports( static::NAVIGATION_POST_TYPE, 'editor' ) );
+       }
+
+       /**
+        * @dataProvider data_should_not_disable
+        * @ticket       56266
+        *
+        * @param string $post_type Post type to test.
+        */
+       public function test_should_not_disable( $post_type ) {
+               $post = $this->create_post( $post_type );
+
+               _disable_content_editor_for_navigation_post_type( $post );
+
+               $this->assertTrue( post_type_supports( $post_type, 'editor' ) );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array
+        */
+       public function data_should_not_disable() {
+               return array(
+                       'post'             => array( 'post' ),
+                       'page'             => array( 'page' ),
+                       'nav_menu_item'    => array( 'nav_menu_item' ),
+                       'oembed_cache'     => array( 'oembed_cache' ),
+                       'user_request'     => array( 'user_request' ),
+                       'wp_block'         => array( 'wp_block' ),
+                       'wp_template'      => array( 'wp_template' ),
+                       'wp_template_part' => array( 'wp_template_part' ),
+                       'wp_global_styles' => array( 'wp_global_styles' ),
+               );
+       }
+
+       /**
+        * @dataProvider data_should_not_change_post_type_support
+        * @ticket       56266
+        *
+        * @param string $post_type Post type to test.
+        */
+       public function test_should_not_change_post_type_support( $post_type ) {
+               $post = $this->create_post( $post_type );
+
+               // Capture the original support.
+               $before = post_type_supports( $post_type, 'editor' );
+
+               _disable_content_editor_for_navigation_post_type( $post );
+
+               // Ensure it did not change.
+               $this->assertSame( $before, post_type_supports( $post_type, 'editor' ) );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array
+        */
+       public function data_should_not_change_post_type_support() {
+               return array(
+                       'post'                => array( 'post' ),
+                       'page'                => array( 'page' ),
+                       'attachments'         => array( 'attachments' ),
+                       'revision'            => array( 'revision' ),
+                       'custom_css'          => array( 'custom_css' ),
+                       'customize_changeset' => array( 'customize_changeset' ),
+                       'nav_menu_item'       => array( 'nav_menu_item' ),
+                       'oembed_cache'        => array( 'oembed_cache' ),
+                       'user_request'        => array( 'user_request' ),
+                       'wp_block'            => array( 'wp_block' ),
+                       'wp_template'         => array( 'wp_template' ),
+                       'wp_template_part'    => array( 'wp_template_part' ),
+                       'wp_global_styles'    => array( 'wp_global_styles' ),
+               );
+       }
+
+       /**
+        * Creates a post.
+        *
+        * @param string $post_type Post type to create.
+        * @return int
+        */
+       private function create_post( $post_type ) {
+               return $this->factory()->post->create(
+                       array( 'post_type' => $post_type )
+               );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/editor/disableContentEditorForNavigationPostType.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestseditorenableContentEditorForNavigationPostTypephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/editor/enableContentEditorForNavigationPostType.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/editor/enableContentEditorForNavigationPostType.php                             (rev 0)
+++ trunk/tests/phpunit/tests/editor/enableContentEditorForNavigationPostType.php       2022-10-04 14:20:18 UTC (rev 54382)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,130 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * @group editor
+ *
+ * @covers ::_enable_content_editor_for_navigation_post_type
+ */
+class Tests_Editor_EnableContentEditorForNavigationPostType extends WP_UnitTestCase {
+       const NAVIGATION_POST_TYPE = 'wp_navigation';
+
+       public function tear_down() {
+               add_post_type_support( static::NAVIGATION_POST_TYPE, 'editor' );
+               parent::tear_down();
+       }
+
+       /**
+        * @ticket 56266
+        */
+       public function test_should_be_enabled_by_default() {
+               $this->assertTrue( post_type_supports( static::NAVIGATION_POST_TYPE, 'editor' ) );
+       }
+
+       /**
+        * @ticket 56266
+        */
+       public function test_should_enable() {
+               $post = $this->create_post( static::NAVIGATION_POST_TYPE );
+
+               _enable_content_editor_for_navigation_post_type( $post );
+
+               $this->assertTrue( post_type_supports( static::NAVIGATION_POST_TYPE, 'editor' ) );
+       }
+
+       /**
+        * @ticket 56266
+        */
+       public function test_should_reenable_when_disabled() {
+               $post = $this->create_post( static::NAVIGATION_POST_TYPE );
+
+               // Set up the test by removing the 'editor' post type support.
+               remove_post_type_support( static::NAVIGATION_POST_TYPE, 'editor' );
+               $this->assertFalse( post_type_supports( static::NAVIGATION_POST_TYPE, 'editor' ) );
+
+               _enable_content_editor_for_navigation_post_type( $post );
+
+               $this->assertTrue( post_type_supports( static::NAVIGATION_POST_TYPE, 'editor' ) );
+       }
+
+       /**
+        * @dataProvider data_should_not_enable
+        * @ticket       56266
+        *
+        * @param string $post_type Post type to test.
+        */
+       public function test_should_not_enable( $post_type ) {
+               $post = $this->create_post( $post_type );
+
+               _enable_content_editor_for_navigation_post_type( $post );
+
+               $this->assertFalse( post_type_supports( $post_type, 'editor' ) );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array
+        */
+       public function data_should_not_enable() {
+               return array(
+                       'invalid post type'   => array( 'book' ),
+                       'attachments'         => array( 'attachments' ),
+                       'revision'            => array( 'revision' ),
+                       'custom_css'          => array( 'custom_css' ),
+                       'customize_changeset' => array( 'customize_changeset' ),
+               );
+       }
+
+       /**
+        * @dataProvider data_should_not_change_post_type_support
+        * @ticket       56266
+        *
+        * @param string $post_type Post type to test.
+        */
+       public function test_should_not_change_post_type_support( $post_type ) {
+               $post = $this->create_post( $post_type );
+
+               // Capture the original support.
+               $before = post_type_supports( $post_type, 'editor' );
+
+               _enable_content_editor_for_navigation_post_type( $post );
+
+               // Ensure it did not change.
+               $this->assertSame( $before, post_type_supports( $post_type, 'editor' ) );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array
+        */
+       public function data_should_not_change_post_type_support() {
+               return array(
+                       'post'                => array( 'post' ),
+                       'page'                => array( 'page' ),
+                       'attachments'         => array( 'attachments' ),
+                       'revision'            => array( 'revision' ),
+                       'custom_css'          => array( 'custom_css' ),
+                       'customize_changeset' => array( 'customize_changeset' ),
+                       'nav_menu_item'       => array( 'nav_menu_item' ),
+                       'oembed_cache'        => array( 'oembed_cache' ),
+                       'user_request'        => array( 'user_request' ),
+                       'wp_block'            => array( 'wp_block' ),
+                       'wp_template'         => array( 'wp_template' ),
+                       'wp_template_part'    => array( 'wp_template_part' ),
+                       'wp_global_styles'    => array( 'wp_global_styles' ),
+               );
+       }
+
+       /**
+        * Creates a post.
+        *
+        * @param string $post_type Post type to create.
+        * @return int
+        */
+       private function create_post( $post_type ) {
+               return $this->factory()->post->create(
+                       array( 'post_type' => $post_type )
+               );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/editor/enableContentEditorForNavigationPostType.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestskseswpFilterGlobalStylesPostphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/kses/wpFilterGlobalStylesPost.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/kses/wpFilterGlobalStylesPost.php                               (rev 0)
+++ trunk/tests/phpunit/tests/kses/wpFilterGlobalStylesPost.php 2022-10-04 14:20:18 UTC (rev 54382)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,83 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * @group kses
+ *
+ * @covers ::wp_filter_global_styles_post
+ */
+class Tests_Kses_WpFilterGlobalStylesPost extends WP_UnitTestCase {
+
+       /**
+        * Theme data.
+        *
+        * @var array
+        */
+       private $user_theme_data = array(
+               'isGlobalStylesUserThemeJSON' => 1,
+               'version'                     => 1,
+               'styles'                      => array(
+                       'blocks' => array(
+                               'core/button' => array(
+                                       'border' => array(
+                                               'radius' => '0',
+                                       ),
+                               ),
+                       ),
+               ),
+       );
+
+       /**
+        * @dataProvider data_should_not_remove_safe_global_style_rules
+        * @ticket       56266
+        *
+        * @param string $rule A rule to test.
+        */
+       public function test_should_not_remove_safe_global_style_rules( $rule ) {
+               $theme_data               = wp_parse_args( $this->user_theme_data, array( $rule => 'someValue' ) );
+               $filtered_user_theme_json = $this->filter_global_styles( $theme_data );
+               $safe_rules               = array_keys( $theme_data );
+               foreach ( $safe_rules as $safe_rule ) {
+                       $this->assertArrayHasKey( $safe_rule, $filtered_user_theme_json, sprintf( 'wp_filter_global_styles_post() must not remove the "%s" rule as it\'s considered safe.', $safe_rule ) );
+               }
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array
+        */
+       public function data_should_not_remove_safe_global_style_rules() {
+               $result = array();
+               foreach ( WP_Theme_JSON::VALID_TOP_LEVEL_KEYS as $safe_rule ) {
+                       $result[ $safe_rule ] = array( $safe_rule );
+               }
+
+               // Settings always get removed.
+               unset( $result['settings'] );
+
+               return $result;
+       }
+
+       /**
+        * @ticket 56266
+        */
+       public function test_should_remove_unsafe_global_style_rules() {
+               $filtered_user_theme_json = $this->filter_global_styles( $this->user_theme_data );
+               $this->assertArrayNotHasKey( 'nonSchemaRule', $filtered_user_theme_json, 'Filtered json data must not contain unsafe global style rules.' );
+       }
+
+       /**
+        * This is a helper method.
+        * It filters JSON theme data and returns it as an array.
+        *
+        * @param array $theme_data Theme data to filter.
+        *
+        * @return array Filtered theme data.
+        */
+       private function filter_global_styles( $theme_data ) {
+               $user_theme_json          = wp_slash( wp_json_encode( $theme_data ) );
+               $filtered_user_theme_json = wp_filter_global_styles_post( $user_theme_json );
+
+               return json_decode( wp_unslash( $filtered_user_theme_json ), true );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/kses/wpFilterGlobalStylesPost.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>