qratorlabs / smocky-phpunit
Extension to wire up Smocky and PHPUnit
2.2.1
2026-02-11 18:43 UTC
Requires
- php: ^8.4
- phpunit/phpunit: ^13.0.0
- qratorlabs/smocky: ^1.2
Requires (Dev)
- phpstan/phpstan: ^2.1
- rector/rector: ^2.3
- squizlabs/php_codesniffer: ^3.12
README
This is a helper library-helper for QratorLabs\Smocky that allows you to use Smocky and PHPUnit together with less boilerplate code.
Installation
composer require --dev "qratorlabs/smocky-phpunit:^1.0||^2.0"
Versioning
This library follows SemVer. But major versions are used to indicate compatibility with PHPUnit versions:
1.xis compatible with PHPUnit 9.6...12.0.82.0is compatible with PHPUnit 12.0.9...12.4.x2.1is compatible with PHPUnit 12.5.0...2.2is compatible with PHPUnit 13.0.0...
Usage
To use with PHPUnit:
MockedMethodto mock method "globally" and use PHPUnit's*Mockers-expects/willReturn/willReturnCallback/...MockedFunction
MockedMethod
The main target is to make mocking static methods easy and feels-n-looks like using PHPUnit.
public function testSomeTest(): void { $methodMock = new MockedMethod($this, SomeClass::class, 'someMethod', once()); $methodMock->getMocker()->willReturn(10); SomeClass::someMethod(); // will return `10` SomeClass::someMethod(); // will cause error (expectation - one call) }