Over the past couple weeks we’ve actual had 3 releases of this library which bring us now to stable version 1.9.0. Together these releases have included a few new features as well as stability enhancements.
Further streamlining of Ajax testing:
Back in version 1.6.0 we introduced the ability to test custom ajax responses with a new helper method called _handleAjaxCustom
. While this works great, it still requires the boilerplate of a try/catch block then using $this->_last_response
.
In this release, we added a new helper method called _getJsonResult
which automatically handles all the boilerplate and returns just the result of the Ajax call.
Maintenance release:
Not long ago WordPress Core introduced visibility declarations to the majority of the testing methods which made for quite a large merge. During this release, the latest (as of November 1st) was merged into this library and is now up to date.
Better handling for bootstrap-no-install.php
was added for tricky Mac environments which do not always play well with environmental variables. There is now an additional WP_TESTS_SKIP_INSTALL
constant available for bootstrapping without clobbering the database. This constant is automatically set within bootstrap-no-install.php
.
Auto generating of attachments:
When testing against attachments, it’s very common to have follow up template tags ,like get_the_post_thumbnail
, called somewhere in the stack. Template tags like these, as well as many core methods, require an actual image file to be present of they will always return empty/null.
This release automatically adds and reuses an image called “test-image.jpg” to any attachment created via self::factory()->attachment->create()
. Now additional calls to image related functions will return expected results.
New assertEqualsSetsValues assertion:
Previously there were 2 assertions available for comparing arrays as sets. They are assertEqualSets
and assertEqualSetsWithIndex
. They work great when you want to compare two arrays that may have a different order.
Now there is a new assertion method called assertEqualsSetsValues
. This compares 2 arrays for both value and order but disregard array keys. This works great for testing two numerical arrays which may have different index starting points. Typically when arrays are generated and/or sliced.