npo / phpunit-extension
Library containing PHPUnit helper classes
1.1
2024-02-13 14:24 UTC
Requires
- php: ^8.3
Requires (Dev)
- dg/bypass-finals: ^1.4.1
- friendsofphp/php-cs-fixer: ^3.13.1
- phpcompatibility/php-compatibility: ^9.3.5
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.9.4
- phpstan/phpstan-phpunit: ^1.3.2
- phpunit/phpunit: ^10.2.6
- squizlabs/php_codesniffer: ^3.7.1
This package is not auto-updated.
Last update: 2024-11-22 12:17:42 UTC
README
A ;ibrary containing phpunit helper classes
Doc
Constraints
Consecutive
The Consecutive
constraint class be used to replace the InvocationMocker::withConsecutive
, which was deprecated as of phpunit version 10. Prior to version 10, consecutive calls could be tested according the following example.
$mockObject
->expects($this->exactly(3))
->method('foo')
->withConsecutive(
['a1', 'a2'],
['b1', 'b2'],
['c1', null],
)'
In version 10 the Consecutive
constraint class can be used to mimic this behavior as illustrated in the following example:
$mockObject
->expects($this->exactly(3))
->method('foo')
->with(
new Consecutive(
'a1',
'b1',
'c1'
),
new Consecutive(
'a2',
// you can also pass constraints
$this->equalTo('b1'),
$this->isNull()
)
);