diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-25 16:46:37 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2018-10-30 21:13:56 +0100 |
commit | c9afc27ab9ea62269967df14a80581ed51ba6c71 (patch) | |
tree | 2580e56b965b5644a28332cc7a527a1a8c5029b1 /tests/Unit | |
parent | fcee7d752f8310aabb76463d61960752ea9ab500 (diff) |
Tests: Moved ServiceProvider::setExpects to TestCase
Diffstat (limited to 'tests/Unit')
-rw-r--r-- | tests/Unit/ServiceProviderTest.php | 29 | ||||
-rw-r--r-- | tests/Unit/TestCase.php | 37 |
2 files changed, 37 insertions, 29 deletions
diff --git a/tests/Unit/ServiceProviderTest.php b/tests/Unit/ServiceProviderTest.php index 149e28f8..ee5e3151 100644 --- a/tests/Unit/ServiceProviderTest.php +++ b/tests/Unit/ServiceProviderTest.php @@ -3,8 +3,6 @@ namespace Engelsystem\Test\Unit; use Engelsystem\Application; -use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder; -use PHPUnit\Framework\TestCase; use PHPUnit_Framework_MockObject_MockObject as MockObject; abstract class ServiceProviderTest extends TestCase @@ -20,31 +18,4 @@ abstract class ServiceProviderTest extends TestCase ->setMethods($methods) ->getMock(); } - - /** - * @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); - } - } } diff --git a/tests/Unit/TestCase.php b/tests/Unit/TestCase.php new file mode 100644 index 00000000..117fba88 --- /dev/null +++ b/tests/Unit/TestCase.php @@ -0,0 +1,37 @@ +<?php + +namespace Engelsystem\Test\Unit; + +use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder; +use PHPUnit\Framework\TestCase as PHPUnitTestCase; +use PHPUnit_Framework_MockObject_MockObject as MockObject; + +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); + } + } +} |