PHPUnit 5 in PhpStorm 9.5

Gary Hockin

PHPUnit 5 has been released, and brings a number of improvements to the most widely used testing framework in PHP. All of the new features and improvements in PHPUnit 5 are supported by PhpStorm 9.5. Let’s take a look at what’s new!

PHPUnitThe big news is that PHPUnit 5 will no longer support versions of PHP lower than 5.6; but it will support PHP 7. This is great news for those who can push forward their PHP versions, but not such good news for those who are locked onto a specific version of PHP. PhpStorm 9.5 already fully supports PHP 5.6, and most PHP 7 features.

Features marked as deprecated in the latter releases of PHPUnit 4 have now been fully removed in 5. These include some assertions (SelectCountSelectRegExpSelectEqualsTagNotTag), some configuration relating to Selenium integration, and the --strict command line argument. Strict mode should now be invoked via a configuration file setting.

There have also been a number of improvements. The way @depends works has been changed – expectations for mock objects that are passed by @depends are evaluated in the test, which is useful in those places where you expect mocked methods to be called in every dependent test.

Tests marked as @small (the default for tests that aren’t size marked) can also be marked as risky if they perform I/O. This should help avoid tests timing out when they perform I/O as the default timeout for small tests is 1 second. Test failures can now be sorted in reverse, and most usefully, a new convenience method getMockWithoutInvokingTheOriginalConstructor was added to quickly create a test double without invoking the original constructor. This will be a useful addition since many developers will be creating mocks without the constructor in lots of tests.

A new --whitelist command line argument has been added which allows you to configure a whitelist of classes for code coverage analysis (using Xdebug).

Finally, a number of new assertions have been added:

  1. assertInfinite – checks that given value is infinite (see is_infinite)
  2. assertFinite – checks that the given value is a finite value (i.e. not infinite)
  3. assertNan – checks that the given value is not a number (see is_nan)

Support for all the new and improved features of PHPUnit 5 is already included in PhpStorm 9.5, and the team at PHPUnit have added a new test result logger into PHPUnit 5 that allows integration with PhpStorm to be even more seamless!

Develop with pleasure!
– JetBrains PhpStorm Team

Subscribe

Subscribe for updates