diff --git a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php index 469a5203f9a7e..ca981f1c77d07 100644 --- a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php @@ -224,6 +224,17 @@ public function set_up() { $this->revision_3_id = $this->revision_3->ID; } + /** + * Sets the current user to the admin, granting super admin on multisite + * so global styles JSON is not stripped by KSES on save. + */ + private function set_admin_user_with_unfiltered_html() { + if ( is_multisite() ) { + grant_super_admin( self::$admin_id ); + } + wp_set_current_user( self::$admin_id ); + } + /** * @ticket 58524 * @ticket 59810 @@ -991,7 +1002,7 @@ public function test_get_global_styles_revisions_pagination() { * @covers WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response */ public function test_get_item_preserves_block_style_variations() { - wp_set_current_user( self::$admin_id ); + $this->set_admin_user_with_unfiltered_html(); switch_theme( 'block-theme-child-with-block-style-variations' ); // Create a global styles post for the theme. @@ -1077,7 +1088,7 @@ public function test_get_item_preserves_block_style_variations() { * @covers WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response */ public function test_multiple_block_variations_are_preserved() { - wp_set_current_user( self::$admin_id ); + $this->set_admin_user_with_unfiltered_html(); switch_theme( 'block-theme-child-with-block-style-variations' ); // Create a global styles post for the theme. @@ -1181,7 +1192,7 @@ public function test_multiple_block_variations_are_preserved() { * @covers WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response */ public function test_theme_variations_are_registered_for_revisions() { - wp_set_current_user( self::$admin_id ); + $this->set_admin_user_with_unfiltered_html(); switch_theme( 'block-theme-child-with-block-style-variations' ); // Verify the theme has a block style variation defined. @@ -1264,7 +1275,7 @@ public function test_theme_variations_are_registered_for_revisions() { * @covers WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response */ public function test_get_items_preserves_block_style_variations() { - wp_set_current_user( self::$admin_id ); + $this->set_admin_user_with_unfiltered_html(); switch_theme( 'block-theme-child-with-block-style-variations' ); // Create a global styles post for the theme.