wordpress/tests/phpunit/includes/testcase-rest-api.php
Sergey Biryukov 62d5c54b67 Tests: Replace most instances of assertEquals() in phpunit/includes/ with assertSame().
Follow-up to [48937], [48939], [48940], [48944].

Props johnbillion, jrf, SergeyBiryukov.
See #38266, #52482.

git-svn-id: https://develop.svn.wordpress.org/trunk@50283 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-10 13:23:42 +00:00

20 lines
513 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->assertSame( $code, $response->get_error_code() );
if ( null !== $status ) {
$data = $response->get_error_data();
$this->assertArrayHasKey( 'status', $data );
$this->assertSame( $status, $data['status'] );
}
}
}