Nette Tester 2.2.0 is out

5 years ago by Miloslav Hůla  

I didn't write a blog article about releasing the 2.1.0. The main purpose of that release was to drop support for PHP below 7.1. Nobody complained so it looks like a good step.

New in Tester

The 2.1.0 version brought one small feature. The --coverage-src parameter is repeatable, so you can mark separated directories for coverage report.

The 2.2.0 version brings a few minor fixes and mainly two new features.

New Tester\Expect object allows you to test “random” items in more complex data structures. You can use them in $expected parameter of Assert::equal() and Assert::notEqual() methods. For example, you test a method which creates a new user and returns its attributes as an array:

use Tester\Expect;

	'id' => 123,
	'username' => 'milo',
	'password' => Expect::match('%h%'),  # random string, hash, but must match some pattern
	'created_at' => Expect::type(DateTimeImmutable::class),  # check type only, not exact value
], User::create(123, 'milo', 'RandomPaSsWoRd'));

Until now, you had to unset these “random” items before assertion or test array items one by one. The usage of Expect is clearer with less effort to type.

You can read more about Expect in documentation.

The second new feature is support for PCOV. I didn't find what that acronym (or is it a word?) means, but it is a PHP extension especially written to provide code coverage functionality. So it is fast. Now, Tester supports three code coverage engines and the question arose about which one to choose when more available. I defined the following priority:

  1. PCOV, because it is a specialized tool
  2. PHPDBG SAPI, because I suppose that the code coverage is the only reason to run it
  3. Xdebug

Many thanks to all contributors!