[wp-trac] [WordPress Trac] #21993: Add WP_DOING_TESTS constant, check for it in WP_Ajax_Response

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 25 21:04:51 UTC 2012


#21993: Add WP_DOING_TESTS constant, check for it in WP_Ajax_Response
-----------------------------+-------------------------
 Reporter:  alexkingorg      |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Unit Tests
  Version:  trunk            |   Severity:  normal
 Keywords:  has-patch        |
-----------------------------+-------------------------
 I'm writing unit tests for #21767 that need to call functions such as
 `wp_ajax_add_tag()`. These functions instantiate a `WP_Ajax_Response`
 object and `send()`, which sends HTTP headers and causes the unit tests to
 fail.

 So far I can't find a way to keep the headers from being sent (anyone know
 how to do this?) so I'm opening this ticket as an alternate solution:
 introduce a WP_DOING_TESTS constant (defined in the bootstrap.php of the
 unit testing framework) and return out of the send() function if that
 constant is set to true.

 Again, happy to be told there is a better way to do this, but definitely
 want to be able to get testing coverage of these "controller" functions.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21993>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list