- Timestamp:
- 05/03/2020 10:56:01 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php
r47360 r47756 457 457 458 458 /** 459 * Test a POST request, with the attributes in the body. 460 * 461 * @ticket 49680 462 */ 463 public function test_get_item_post_request() { 464 wp_set_current_user( self::$user_id ); 465 $string_attribute = 'Lorem ipsum dolor'; 466 $attributes = array( 'some_string' => $string_attribute ); 467 $request = new WP_REST_Request( 'POST', self::$rest_api_route . self::$block_name ); 468 $request->set_param( 'context', 'edit' ); 469 $request->set_header( 'content-type', 'application/json' ); 470 $request->set_body( wp_json_encode( compact( 'attributes' ) ) ); 471 $response = rest_get_server()->dispatch( $request ); 472 473 $this->assertEquals( 200, $response->get_status() ); 474 $this->assertContains( $string_attribute, $response->get_data()['rendered'] ); 475 } 476 477 /** 459 478 * Test getting item with invalid post ID. 460 479 * … … 504 523 $data = $response->get_data(); 505 524 506 $this->assertEqualSets( array( 'GET' ), $data['endpoints'][0]['methods'] );525 $this->assertEqualSets( array( 'GET', 'POST' ), $data['endpoints'][0]['methods'] ); 507 526 $this->assertEqualSets( 508 527 array( 'name', 'context', 'attributes', 'post_id' ),
Note: See TracChangeset
for help on using the changeset viewer.