Skip to content

Commit 2c19861

Browse files
committed
Update failing test, add test for allowed CSS
1 parent e3a6d78 commit 2c19861

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/phpunit/tests/rest-api/rest-global-styles-controller.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ public function test_update_item_valid_styles_css() {
650650
/**
651651
* @covers WP_REST_Global_Styles_Controller::update_item
652652
* @ticket 57536
653+
* @ticket 64418
653654
*/
654655
public function test_update_item_invalid_styles_css() {
655656
wp_set_current_user( self::$admin_id );
@@ -659,7 +660,9 @@ public function test_update_item_invalid_styles_css() {
659660
$request = new WP_REST_Request( 'PUT', '/wp/v2/global-styles/' . self::$global_styles_id );
660661
$request->set_body_params(
661662
array(
662-
'styles' => array( 'css' => '<p>test</p> body { color: red; }' ),
663+
'styles' => array(
664+
'css' => '</style would close the containing element and is not allowed.',
665+
),
663666
)
664667
);
665668
$response = rest_get_server()->dispatch( $request );
@@ -826,4 +829,32 @@ public function test_global_styles_route_args_schema() {
826829
$this->assertArrayHasKey( 'type', $route_data[0]['args']['id'] );
827830
$this->assertSame( 'integer', $route_data[0]['args']['id']['type'] );
828831
}
832+
833+
/**
834+
* @covers WP_REST_Global_Styles_Controller::update_item
835+
* @ticket 64418
836+
*/
837+
public function test_update_allows_valid_css_with_more_syntax() {
838+
wp_set_current_user( self::$admin_id );
839+
if ( is_multisite() ) {
840+
grant_super_admin( self::$admin_id );
841+
}
842+
$request = new WP_REST_Request( 'PUT', '/wp/v2/global-styles/' . self::$global_styles_id );
843+
$css = <<<'CSS'
844+
@property --animate {
845+
syntax: "<custom-ident>";
846+
inherits: true;
847+
initial-value: false;
848+
}
849+
CSS;
850+
$request->set_body_params(
851+
array(
852+
'styles' => array( 'css' => $css ),
853+
)
854+
);
855+
856+
$response = rest_get_server()->dispatch( $request );
857+
$data = $response->get_data();
858+
$this->assertSame( $css, $data['styles']['css'] );
859+
}
829860
}

0 commit comments

Comments
 (0)