Release 2.5.0
@atoum/RMs - 08 Jan 2016
Stats
- 45 commits,
- 69 files changed,
- 6 contributors,
- 8 new features,
- 3 bug fixes.
What’s new
Asserting on child arrays
Asserting on arrays has just become a bit more awesome. Remember when you wanted to assert on child arrays, you had to do things like:
The chain was broken because you were not able to easily assert on child arrays. With this new release, atoum brings a new helper method to do this:
You might also know that atoum provides an alternative syntax to assert on child arrays:
Just choose the one you prefer and fits the best to your needs.
castToArray
and iterator
asserters
This is now possible to assert on iterators thanks to a dedicated iterator
asserter group:
This asserter will only check that the subject value implements the Iterator
interface and will allow you to use a
single hasSize
assertion as regular iterators can’t be randomly accessed.
castToArray
to the rescue: This new asserter will let you cast any value to an array to assert on it. This is very usefull
with iterators:
There is also a toArray
shortcut method to cast any iterator
or string
asserter group to an array:
resource
asserter
The resource
asserter group provides useful asserters to check resources’ types. For instance:
is true if the resource $var
is a stream. In many cases, we can use the is*
magic methods as a replacement of isOfType
. Thus:
is strictly equivalent.
Finally, if you would like more thinner asserters on the type of the resource, you can use ->resource($var)->type->…
where type
returns a string
asserter group.
Discover all the available resources in PHP at http://php.net/resource.
Improvements on mock
Mock generator has been updated to support variadic arguments passed by reference. Method declared with such arguments will be correctly mocked.
Another interesting feature around mocks is the automatic mock generation and injection. When you wanted to use mocks in a test, you had to do things like:
Now instead of manually generating the mock, you can ask atoum to do it for you:
When you add type-hints to a test method (which is not associated with a data provider) atoum will automatically generate mocks for its arguments ad inject them automatically.
atoum has always provided a simple and nice way of generating mocks: you simply have to instanciate a class with top-namespace mock\
. Some users don’t like this so we added a new helper method on test classes:
Of course, this method provides the exatc same features as the previous one: you can mock concrete classes, abstract classes and interfaces.
Asides
Stubs
atoum stubs has been updated according to the features introduced in this release. Don’t forget to add
them to your composer.json
if you want to have a better IDE integration (like autocompletion).
Extensions
Some extensions have been updated:
- The deprecated-extension has been published,
- The blackfire-extension has been published,
- The ruler-extension has been updated with 4 new features, see the changelog.
Thanks Adrien Gallou for the amazing work he did on those extensions!
Documentation
We also updated missing parts of the documentation. Again, Adrien Gallou and our two doc masters did an amazing job!