mirror of
https://github.com/danog/amp.git
synced 2024-12-03 18:07:57 +01:00
27 lines
671 B
PHP
27 lines
671 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Amp;
|
|
|
|
class TestCase extends \PHPUnit\Framework\TestCase
|
|
{
|
|
final protected function createCallback(
|
|
int $invocationCount,
|
|
?callable $returnCallback = null,
|
|
array $expectArgs = [],
|
|
): \Closure {
|
|
$mock = $this->createMock(CallbackStub::class);
|
|
$invocationMocker = $mock->expects(self::exactly($invocationCount))
|
|
->method('__invoke');
|
|
|
|
if ($returnCallback) {
|
|
$invocationMocker->willReturnCallback($returnCallback);
|
|
}
|
|
|
|
if ($expectArgs) {
|
|
$invocationMocker->with(...$expectArgs);
|
|
}
|
|
|
|
return $mock(...);
|
|
}
|
|
}
|