<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eboreum / phpunit-with-consecutive-alternative example snippets
use Eboreum\PhpunitWithConsecutiveAlternative\MethodCallExpectation;
use Eboreum\PhpunitWithConsecutiveAlternative\WillHandleConsecutiveCalls;
...
$object = $this->createMock(DateTime::class);
$willHandleConsecutiveCalls = new WillHandleConsecutiveCalls();
$willHandleConsecutiveCalls->expectConsecutiveCalls(
$object,
'setISODate',
new MethodCallExpectation($object, 1999, 42),
new MethodCallExpectation($object, 2000, 43, 2),
);
...
$this->assertSame($object, $object->setISODate(1999, 42));
$this->assertSame($object, $object->setISODate(2000, 43, 2));
use Eboreum\PhpunitWithConsecutiveAlternative\MethodCallExpectation;
use Eboreum\PhpunitWithConsecutiveAlternative\WillHandleConsecutiveCalls;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
abstract class AbstractUnitTestCase extends TestCase
{
/**
* @param non-empty-string $methodName
*/
final public static function expectConsecutiveCalls(
MockObject $object,
string $methodName,
MethodCallExpectation ...$methodCallExpectations,
): void {
(new WillHandleConsecutiveCalls())->expectConsecutiveCalls($object, $methodName, ...$methodCallExpectations);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.