etel/phpunit-double

Provides double configurators with fluent interface support.

Maintainers

Package info

github.com/etel-soft/phpunit-double

pkg:composer/etel/phpunit-double

Statistics

Installs: 70

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-05-04 16:28 UTC

This package is auto-updated.

Last update: 2026-05-04 16:30:33 UTC


README

CI Status codecov Latest Stable Version License PHP Version Require

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();