blob: e4fdff7b3c59e22103c64a60bc6adfc7e8d06213 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
namespace Jasny\Router;
use PHPUnit_Framework_MockObject_Matcher_Invocation as Invocation;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Helper methods for PHPUnit tests
*/
trait TestHelpers
{
/**
* Create mock for next callback
*
* @param Invocation $matcher
* @param array $with With arguments
* @param mixed $return
* @return MockObject
*/
protected function createCallbackMock(Invocation $matcher, $with = [], $return = null)
{
$callback = $this->getMockBuilder(\stdClass::class)->setMethods(['__invoke'])->getMock();
$callback->expects($matcher)->method('__invoke')
->with(...$with)
->willReturn($return);
return $callback;
}
}
|