summaryrefslogtreecommitdiff
path: root/tests/Unit/ServiceProviderTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-10-31 14:15:19 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-10-31 14:15:19 +0100
commit411ea5bb6d0ecf32e6c989a99fac120502db9fe9 (patch)
tree736b66c00b26dac8fc9cf4283d4888b0b69b9816 /tests/Unit/ServiceProviderTest.php
parent915cbee3e099cc7d48f71f6627b5fde3942cbe88 (diff)
Refactored service provider tests
Diffstat (limited to 'tests/Unit/ServiceProviderTest.php')
-rw-r--r--tests/Unit/ServiceProviderTest.php31
1 files changed, 21 insertions, 10 deletions
diff --git a/tests/Unit/ServiceProviderTest.php b/tests/Unit/ServiceProviderTest.php
index be843742..dc58a65e 100644
--- a/tests/Unit/ServiceProviderTest.php
+++ b/tests/Unit/ServiceProviderTest.php
@@ -4,33 +4,44 @@ namespace Engelsystem\Test\Unit;
use Engelsystem\Application;
use PHPUnit\Framework\TestCase;
-use PHPUnit_Framework_MockObject_MockObject;
+use PHPUnit_Framework_MockObject_Matcher_InvokedRecorder as InvokedRecorder;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
abstract class ServiceProviderTest extends TestCase
{
/**
* @param array $methods
- * @return Application|PHPUnit_Framework_MockObject_MockObject
+ * @return Application|MockObject
*/
protected function getApp($methods = ['make', 'instance'])
{
- /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */
+ /** @var MockObject|Application $app */
return $this->getMockBuilder(Application::class)
->setMethods($methods)
->getMock();
}
/**
- * @param PHPUnit_Framework_MockObject_MockObject $object
- * @param string $method
- * @param array $arguments
- * @param mixed $return
+ * @param MockObject $object
+ * @param string $method
+ * @param array $arguments
+ * @param mixed $return
+ * @param InvokedRecorder $times
*/
- protected function setExpects($object, $method, $arguments, $return = null)
+ protected function setExpects($object, $method, $arguments = null, $return = null, $times = null)
{
- $invocation = $object->expects($this->once())
+ if (is_null($times)) {
+ $times = $this->once();
+ }
+
+ $invocation = $object->expects($times)
->method($method);
- call_user_func_array([$invocation, 'with'], $arguments);
+
+ if (is_null($arguments)) {
+ $invocation->withAnyParameters();
+ } else {
+ call_user_func_array([$invocation, 'with'], $arguments);
+ }
if (!is_null($return)) {
$invocation->willReturn($return);