etel / phpunit-double
Provides double configurators with fluent interface support.
v0.1.1
2026-05-04 16:28 UTC
Requires
- php: >=8.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/phpstan: ^2.1
- phpunit/phpunit: >=13.0
- symfony/property-access: ^7.0|^8.0
This package is auto-updated.
Last update: 2026-05-04 16:30:33 UTC
README
Configurators for PHPUnit test doubles
Provides double configurators with fluent interface support.
In active development, so API can change. Part of the methods (mostly for Mock) are missed and will be added in near future.
Usage example
Before:
$anotherStub = $this->createStub(AnotherInterface::class); $anotherStub->method('handle')->willReturnCallback($callback)->seal(); $stub = $this->createStub(SomeInterface::class); $stub->method('steps')->willReturn(5); $stub->method('next')->willReturn($anotherStub)->seal();
After:
$stub = $this->createStubConfig(type: SomeInterface::class) ->addMethodReturns(name: 'steps', return: 5) ->addMethodReturns( name: 'next', return: $this->createStubConfig(type: AnotherInterface::class) ->addMethodReturnsCallback(name: 'handle', callback: $callback) ->getSealedStub() ) ->getSealedStub();