WP_Test_REST_TestCase::assertErrorResponse PHP Method

assertErrorResponse() protected method

protected assertErrorResponse ( $code, $response, $status = null )
    protected function assertErrorResponse($code, $response, $status = null)
    {
        if (is_a($response, 'WP_REST_Response')) {
            $response = $response->as_error();
        }
        $this->assertInstanceOf('WP_Error', $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']);
        }
    }
WP_Test_REST_TestCase