wordpress/tests/phpunit/includes/testcase-rest-api.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
513 B
PHP
Raw Normal View History

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