- Guide
- Playground
- GitHub
-
Ecosystem
Help
Resource Lists
Recent Posts
- What's new in Infection 0.26.0
- What's new in Infection 0.25.0
- What's new in Infection 0.24.0
- What's new in Infection 0.23.0
- What's new in Infection 0.21.0
- What's new in Infection 0.20.0
- What's new in Infection 0.19.0
- What's new in Infection 0.18.0
- What's new in Infection 0.17.0
- What's new in Infection 0.16.0
What's new in Infection 0.13.0
May 18, 2019
Release: https://github.com/infection/infection/releases/tag/0.13.0
New features and enhancements
Proper array coverage
As shown on the image below, array coverage is a bit wonky in PHP, and not all items are considered covered.
Before 0.13.0
, mutants, created from not covered lines could not be killed.
Now, even with such coverage results, Infection will treat those white lines as covered so you can kill generated Mutants.
pcov
support
We’ve added a preliminary support for pcov
- quite new CodeCoverage compatible driver for PHP.
Ignore mutator on particular line of the code
It was possible to disable (ignore) mutators for classes and methods using wildcards.
Now it’s also possible to disable mutators just for one line of the code:
{ |
--no-progress
option (automatically enabled on CI server)
The amount of text generated by the initial processes (running tests, generating mutations) is quite big, specially when running it on medium to large projects. This is basically due to the progress bars that are being used and that, for CI environments without proper ANSI support, is quite irrelevant.
It’s better to show it with the screenshot:
Now Infection does not output this information if --no-progress
option is used or if CI is automatically detected:
For example, there is no need to add this option on Travis.
New Mutators
Starting from 0.13.0
Infection supports mutation of functions from 2 PHP extensions:
ext-bcmath
ext-mbstring
bcmath
mutators
The aim of this set of mutators is to ensure project really needs this extension. If you are working with arbitrary precision arithmetic or with really big int
numbers - your tests must know about that.
One of the examples of mutation produced by this mutator is:
- $bigIntInString = bcadd($a, b); |
Either kill it or don’t use bc*
functions - they are used without a real reason.
See all
bcmath
mutators on the corresponded documentation page.
mbstring
mutators
It is common to see people use multibyte string functions (like mb_strlen()
) instead of their common analogs (like strlen()
), while not writing any tests exploiting multibyte functionality.
In this situations mutators as simple as below could be of use:
- if (mb_strlen($str) < 10) { |
See all
mbstring
mutators on the corresponded documentation page.
Array item removal mutator
Removes an item (or items) from the array, depending on Mutator settings.
Example:
- $keywords = ['select', 'from', 'where']; |
Configuration options:
remove: first
: defines the way the mutator operates. Could be:first
- remove only first element from each arraylast
- remove only last element from each arrayall
- remove every element one by one from each array resulting in as many mutations as total number of items in arrays.
limit: PHP_INT_MAX
: whenremove = all
specifies maximum number of elements that will be removed form array. Only elements at the beginning will be mutated.
For more information, see the corresponded documentation page
AssignCoalesce
mutator
- $this->request->data['comments']['user_id'] ??= 'value'; |
See https://wiki.php.net/rfc/null_coalesce_equal_operator
@unwrap
profile - added last mutators
We’ve added many new mutators that unwrap the function call
- $a = array_intersect_assoc(['A', 1, 'C'], ['D']); |
New functions in 0.13.0
are:
array_intersect_assoc
array_pad
array_udiff
array_udiff_uassoc
array_uintersect
array_uintersect_assoc
array_uintersect_uassoc
lcfirst
trim
ucfirst
ucwords
All new ideas are tracked here: https://github.com/infection/infection/issues/514
See all existing@unwrap
mutators on the corresponded documentation page.
There are also many bugfixes in 0.13.0
, please upgrade!
Enjoy!