Changeset 62107 for trunk/tests/phpunit/tests/rest-api/rest-server.php
- Timestamp:
- 03/24/2026 05:38:12 PM (4 days ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/rest-api/rest-server.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-server.php
r60635 r62107 591 591 $this->assertSame( 'more_data', $response->get_data()['data'] ); 592 592 $this->assertSame( array( array( 'status' => 400 ) ), $response->get_data()['additional_data'] ); 593 } 594 595 /** 596 * @ticket 64901 597 */ 598 public function test_error_to_response_with_stdclass_data() { 599 $error = new WP_Error( 'test', 'test', (object) array( 'status' => 400 ) ); 600 601 $response = rest_convert_error_to_response( $error ); 602 $this->assertInstanceOf( WP_REST_Response::class, $response ); 603 604 // stdClass data should not cause a fatal, status should default to 500. 605 $this->assertSame( 500, $response->get_status() ); 606 } 607 608 /** 609 * @ticket 64901 610 */ 611 public function test_error_to_response_with_multi_status_non_numeric_status() { 612 $error = new WP_Error( 'test', 'test', array( 'status' => array( 'feeling' => 'happy' ) ) ); 613 $error->add_data( array( 'status' => 400 ), 'test' ); 614 $error->add_data( array( 'status' => array( 'feeling' => 'bleh' ) ), 'test' ); 615 616 $response = rest_convert_error_to_response( $error ); 617 $this->assertInstanceOf( WP_REST_Response::class, $response ); 618 619 $this->assertSame( 400, $response->get_status() ); 593 620 } 594 621
Note: See TracChangeset
for help on using the changeset viewer.