[wp-trac] [WordPress Trac] #36166: wp_die() doesn't accept a WP_Error during unit testing

WordPress Trac noreply at wordpress.org
Tue Mar 22 19:02:45 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:  Awaiting Review
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+------------------------------

Comment (by boonebgorges):

 Could I get some more details on how to reproduce? It seems as if the
 issue being reported by @xoogu in the support forums is somewhat different
 from what's being proposed by @utkarshpatel. @dd32 suggests that the AJAX
 die handler for unit tests should match the `src` handler. But this should
 already be the case:

 *
 https://core.trac.wordpress.org/browser/tags/4.4.2/tests/phpunit/includes
 /testcase-ajax.php#L134
 * https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-
 includes/functions.php#L2719

 In each case, a scalar value is handled one way (printing or passing to
 the `Exception`), while all other values die with `'0'`.

 [attachment:36166_1.patch] proposes an enhancement that passes custom
 `WP_Error` messages to the die handler. This may be a viable enhancement,
 but it doesn't address the original report, which suggests that errors are
 handled differently in the context of unit tests.

 Possibly related, AJAX test classes are responsible for providing their
 own die handlers. Core tests do this by extending `WP_Ajax_UnitTestCase`.
 If @utkarshpatel's tests are invoking the default
 `_ajax_wp_die_handler()`, I'm guessing that those tests are *not*
 extending `WP_Ajax_UnitTestCase`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36166#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list