Skip to content

Releases: lipemat/wp-unit

Version 3.6.0

19 Mar 20:06
3.6.0
294a30f
Compare
Choose a tag to compare

Version 3.5.0

21 Oct 18:59
3.5.0
1f1bcfd
Compare
Choose a tag to compare

Version 3.4.1

03 Oct 18:10
3.4.1
1c20084
Compare
Choose a tag to compare

Version 3.4.0

03 Oct 18:03
3.4.0
7f9128d
Compare
Choose a tag to compare

Version 3.3.0

29 Jun 14:32
3.3.0
88b46a5
Compare
Choose a tag to compare

Support `assertEqualSetsValues` on all TestCases

05 Nov 17:14
Compare
Choose a tag to compare

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' )
		)

Full Release Notes

Maintenance Release

01 Nov 20:42
Compare
Choose a tag to compare

Merge in lastest from fork of WP Core

  1. Now up to date with anything that is included WP Core (89621877f823c1246e1b93ddcd32b68870e71114). 61834a2
  2. Better handling of "bootstrap-no-install" for tricky Mac environments. 899f5cd
  3. Automatically generate images to go along with attachments. 2ab74ee

Streamlined `wp_send_json_success` handling.

31 Oct 21:35
Compare
Choose a tag to compare

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

10 Jun 19:54
Compare
Choose a tag to compare

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

03 Jun 16:43
Compare
Choose a tag to compare

Maintenance Release

  1. Support an outside languages directory.
  2. Prevent third party plugins from breaking MySQL transactions.
  3. Allow pre version 5.0.0 sites to run.
  4. Mimic wp core's new wp_get_ready_cron_jobs() function.