[wp-trac] [WordPress Trac] #36166: wp_die() doesn't accept a WP_Error during unit testing
WordPress Trac
noreply at wordpress.org
Wed Mar 23 18:53:05 UTC 2016
#36166: wp_die() doesn't accept a WP_Error during unit testing
------------------------------+------------------
Reporter: dd32 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.5
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
------------------------------+------------------
Changes (by boonebgorges):
* milestone: Awaiting Review => 4.5
Comment:
Replying to [comment:5 dd32]:
> To test it, I simply added that example to the functions.php unit tests:
> {{{
> + function test_wp_die_with_wp_error() {
> + wp_die( new WP_Error( 'test', 'test' ) );
> + }
> }}}
>
> and got the fatal error as stated.
>
> It turns out that the Ajax wp_die() handler handles it correctly, but
the `WP_UnitTest` wp_die handler doesn't:
https://core.trac.wordpress.org/browser/tags/4.4.2/tests/phpunit/includes/testcase.php#L274
Ah yes. Thanks for the pointer. This is what I was guessing at in
[comment:4 this comment].
@utkarshpatel The proposal that `wp_die()` print `WP_Error` messages is
worth considering, but it's beyond the scope of this ticket. The proposal
raises a number of concerns related to backward compatibility, empty
messages, and other potential problems. If you'd like to consider it, I
encourage you to open an enhancement ticket.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36166#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list