diff options
Diffstat (limited to 'tests/support/TestHelpers.php')
-rw-r--r-- | tests/support/TestHelpers.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/support/TestHelpers.php b/tests/support/TestHelpers.php new file mode 100644 index 0000000..e4fdff7 --- /dev/null +++ b/tests/support/TestHelpers.php @@ -0,0 +1,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; + } +} |