Releases: lipemat/wp-unit
Releases · lipemat/wp-unit
Version 3.6.0
3.6.0
Version 3.5.0
3.5.0
Version 3.4.1
3.4.1
Version 3.4.0
3.4.0
Version 3.3.0
3.3.0
Support `assertEqualSetsValues` on all TestCases
Support testing two arrays of values while accounting for order but ignoring array keys.
Useful for testing things like pagination.
Example:
$categories = \get_categories( [
'orderby' => 'term_id',
'order' => 'ASC',
] );
$per_page = 20;
$this->assertEqualSetsValues(
wp_list_pluck( array_slice( $categories, $per_page * 4, $per_page ), 'term_id' ),
wp_list_pluck( $this->get_results( 5 )->categories, 'id' )
)
Maintenance Release
Streamlined `wp_send_json_success` handling.
Now testing AJAX is about as simple as it can get.
New method available on the WP_Ajax_UnitTestCase
class:
/**
* Capture and return the "data" key from any call to
* `wp_send_json_success` or `wp_send_json_error`.
*
* Automatically handles:
* 1. Reset $this->_last_response
* 2. Catch the exception
* 3. Return the result that would be sent as `data`.
*
* @author Mat Lipe
*
* @since 1.7.0
*
* @param callable $callable
*
* @return mixed
*/
protected function _getJsonResult( callable $callable ) {
unset( $this->_last_response );
try {
$this->_handleAjaxCustom( $callable );
} catch ( \Exception $exception ) {
return json_decode( $this->_last_response )->data;
}
}
No more boilerplate or try/catch need to test typical results.
Must be using standard wp_send_json_success
or wp_send_json_error
functions to use this. Or at least by following the same wp_die
and data
key patterns.
Custom Ajax Method Handling
Support custom ajax methods.
Sometimes you want to use ajax repsonses to calls which live outside the wp_ajax
actions.
This library adds a method to WP_Ajax_UnitTestCase
called _handleAjaxCustom
to support this.
Maintenance Release
Maintenance Release
- Support an outside languages directory.
- Prevent third party plugins from breaking MySQL transactions.
- Allow pre version 5.0.0 sites to run.
- Mimic wp core's new wp_get_ready_cron_jobs() function.