- Timestamp:
- 02/02/2023 06:50:54 PM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-global-styles-controller.php
r55177 r55192 533 533 } 534 534 } 535 536 /** 537 * @covers WP_REST_Global_Styles_Controller::update_item 538 * @ticket 57536 539 */ 540 public function test_update_item_valid_styles_css() { 541 wp_set_current_user( self::$admin_id ); 542 if ( is_multisite() ) { 543 grant_super_admin( self::$admin_id ); 544 } 545 $request = new WP_REST_Request( 'PUT', '/wp/v2/global-styles/' . self::$global_styles_id ); 546 $request->set_body_params( 547 array( 548 'styles' => array( 'css' => 'body { color: red; }' ), 549 ) 550 ); 551 $response = rest_get_server()->dispatch( $request ); 552 $data = $response->get_data(); 553 $this->assertSame( 'body { color: red; }', $data['styles']['css'] ); 554 } 555 556 /** 557 * @covers WP_REST_Global_Styles_Controller::update_item 558 * @ticket 57536 559 */ 560 public function test_update_item_invalid_styles_css() { 561 wp_set_current_user( self::$admin_id ); 562 if ( is_multisite() ) { 563 grant_super_admin( self::$admin_id ); 564 } 565 $request = new WP_REST_Request( 'PUT', '/wp/v2/global-styles/' . self::$global_styles_id ); 566 $request->set_body_params( 567 array( 568 'styles' => array( 'css' => '<p>test</p> body { color: red; }' ), 569 ) 570 ); 571 $response = rest_get_server()->dispatch( $request ); 572 $this->assertErrorResponse( 'rest_custom_css_illegal_markup', $response, 400 ); 573 } 535 574 }
Note: See TracChangeset
for help on using the changeset viewer.