Changeset 50150 for trunk/tests/phpunit/tests/rest-api/rest-server.php
- Timestamp:
- 02/02/2021 05:26:06 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-server.php
r49925 r50150 408 408 $error = new WP_Error( $code, $message ); 409 409 410 $response = rest_ get_server()->error_to_response( $error );410 $response = rest_convert_error_to_response( $error ); 411 411 $this->assertInstanceOf( 'WP_REST_Response', $response ); 412 412 … … 425 425 $error = new WP_Error( $code, $message, array( 'status' => 400 ) ); 426 426 427 $response = rest_ get_server()->error_to_response( $error );427 $response = rest_convert_error_to_response( $error ); 428 428 $this->assertInstanceOf( 'WP_REST_Response', $response ); 429 429 … … 444 444 $error->add( $code2, $message2, array( 'status' => 403 ) ); 445 445 446 $response = rest_ get_server()->error_to_response( $error );446 $response = rest_convert_error_to_response( $error ); 447 447 $this->assertInstanceOf( 'WP_REST_Response', $response ); 448 448 … … 455 455 $this->assertSame( $message2, $error->errors[ $code2 ][0] ); 456 456 $this->assertSame( array( 'status' => 403 ), $error->error_data[ $code2 ] ); 457 } 458 459 /** 460 * @ticket 46191 461 */ 462 public function test_error_to_response_with_additional_data() { 463 $error = new WP_Error( 'test', 'test', array( 'status' => 400 ) ); 464 $error->add_data( 'more_data' ); 465 466 $response = rest_convert_error_to_response( $error ); 467 $this->assertSame( 400, $response->get_status() ); 468 $this->assertEquals( 'more_data', $response->get_data()['data'] ); 469 $this->assertEquals( array( array( 'status' => 400 ) ), $response->get_data()['additional_data'] ); 457 470 } 458 471
Note: See TracChangeset
for help on using the changeset viewer.