mirror of
git://develop.git.wordpress.org/
synced 2025-02-23 08:03:41 +01:00
This is a micro-optimization that removes a few unnecessary function calls. Follow-up to [31188], [34369], [38986], [41159], [43211], [43230], [44606], [45757]. Props ayeshrajans, jrf, rajinsharwar, costdev, mukesh27, SergeyBiryukov. Fixes #58943. git-svn-id: https://develop.svn.wordpress.org/trunk@56352 602fd350-edb4-49c9-b593-d223f7449a82
20 lines
513 B
PHP
20 lines
513 B
PHP
<?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'] );
|
|
}
|
|
}
|
|
}
|