2018-09-25 16:46:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder;
|
2019-04-24 10:45:00 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2018-09-25 16:46:37 +02:00
|
|
|
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
|
|
|
|
|
|
|
|
abstract class TestCase extends PHPUnitTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param MockObject $object
|
|
|
|
* @param string $method
|
|
|
|
* @param array $arguments
|
|
|
|
* @param mixed $return
|
|
|
|
* @param InvokedRecorder $times
|
|
|
|
*/
|
|
|
|
protected function setExpects($object, $method, $arguments = null, $return = null, $times = null)
|
|
|
|
{
|
|
|
|
if (is_null($times)) {
|
|
|
|
$times = $this->once();
|
|
|
|
}
|
|
|
|
|
|
|
|
$invocation = $object->expects($times)
|
|
|
|
->method($method);
|
|
|
|
|
|
|
|
if (is_null($arguments)) {
|
|
|
|
$invocation->withAnyParameters();
|
|
|
|
} else {
|
|
|
|
call_user_func_array([$invocation, 'with'], $arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_null($return)) {
|
|
|
|
$invocation->willReturn($return);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|