[Wp-unit-tests] [WordPress Unit Tests] #40: Improve wp_die handling in ajax tests
WordPress Unit Tests
noreply at wordpress.org
Thu May 24 01:26:28 UTC 2012
#40: Improve wp_die handling in ajax tests
--------------------------+------------------------------------
Reporter: kurtpayne | Owner:
Type: defect | Status: new
Priority: major | Milestone: Improve Test Framework
Component: Capabilities | Version:
Keywords: ajax |
--------------------------+------------------------------------
WordPress expects wp_die() to end script execution. The unit tests do not
handle this correctly right now. The die handler method only stops
execution (via exception) if wp_die is called with a non-empty argument.
{{{
public function dieHandler( $message ) {
$this->_last_response = $message;
if ( !empty( $message ) ) {
ob_end_clean();
throw new WPAjaxDieException( $message );
}
}
}}}
This means calls like `wp_die()`, `wp_die('')`, and `wp_die(0)` do not
halt execution and the code continues running. Some of the ajax tests are
currently wrong because of this.
I suggest we use two exceptions - `WPAjaxDieContinueException` to signal a
normal halt in code execution (e.g. `WP_Ajax_Response::send()`) and
`WPAjaxDieStopException` to signal an unexpected stop in execution (an
error condition, e.g. a failed nonce check).
--
Ticket URL: <https://unit-test.trac.wordpress.org/ticket/40>
WordPress Unit Tests <https://unit-test.trac.wordpress.org>
My example project
More information about the wp-unit-tests
mailing list