wordpress-develop/tests/phpunit/includes/testcase-rest-api.php
John Blackbourn 82e44bc702 Build/Test Tools: Misc test enhancements.
See #51344


git-svn-id: https://develop.svn.wordpress.org/trunk@49606 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-15 17:17:55 +00:00

20 lines
517 B
PHP

<?php
abstract class WP_Test_REST_TestCase extends WP_UnitTestCase {
protected function assertErrorResponse( $code, $response, $status = null ) {
if ( is_a( $response, 'WP_REST_Response' ) ) {
$response = $response->as_error();
}
$this->assertWPError( $response );
$this->assertEquals( $code, $response->get_error_code() );
if ( null !== $status ) {
$data = $response->get_error_data();
$this->assertArrayHasKey( 'status', $data );
$this->assertEquals( $status, $data['status'] );
}
}
}