summaryrefslogtreecommitdiff
path: root/tests/Unit/ServiceProviderTest.php
blob: be84374288836a079483f399ffdfd4d19ebf27b2 (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
31
32
33
34
35
36
37
38
39
<?php

namespace Engelsystem\Test\Unit;

use Engelsystem\Application;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;

abstract class ServiceProviderTest extends TestCase
{
    /**
     * @param array $methods
     * @return Application|PHPUnit_Framework_MockObject_MockObject
     */
    protected function getApp($methods = ['make', 'instance'])
    {
        /** @var PHPUnit_Framework_MockObject_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
     */
    protected function setExpects($object, $method, $arguments, $return = null)
    {
        $invocation = $object->expects($this->once())
            ->method($method);
        call_user_func_array([$invocation, 'with'], $arguments);

        if (!is_null($return)) {
            $invocation->willReturn($return);
        }
    }
}