[wp-trac] [WordPress Trac] #60426: Update WP_Test_REST_TestCase::assertErrorResponse() to allow custom failure messages
WordPress Trac
noreply at wordpress.org
Fri Feb 2 12:21:08 UTC 2024
#60426: Update WP_Test_REST_TestCase::assertErrorResponse() to allow custom failure
messages
------------------------------+-----------------------------
Reporter: antonvlasenko | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords: needs-patch
Focuses: coding-standards |
------------------------------+-----------------------------
According to the WordPress coding standards, it is recommended that if
there are more than 2 assertions in a single test method, these assertions
should include custom failure messages to explain the nature of any failed
assertions.
However, in the current state of the
`WP_Test_REST_TestCase::assertErrorResponse()` helper method, it contains
2 assertions, making it impossible to add a custom message explaining the
error.
To align with coding standards and improve the clarity of test failures, I
propose updating the method's signature as follows:
{{{
protected function assertErrorResponse($code, $response, $status = null,
$failure_message)
}}}
This change will allow developers to include a custom message when using
the `WP_Test_REST_TestCase::assertErrorResponse()` method, improving the
ability to diagnose issues during testing.
Furthermore, all the instances where this method is being used across the
codebase need to be refactored to include the new `$failure_message`
parameter, ensuring consistency.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60426>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list