summaryrefslogtreecommitdiff
path: root/tests/Unit/Config/ConfigServiceProviderTest.php
blob: 26128e79d25f666e9c7489a48af6a90288d7bd3d (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

namespace Engelsystem\Test\Config;

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

class ConfigServiceProviderTest extends TestCase
{
    /**
     * @covers \Engelsystem\Config\ConfigServiceProvider::register()
     */
    public function testRegister()
    {
        /** @var PHPUnit_Framework_MockObject_MockObject|Config $config */
        $config = $this->getMockBuilder(Config::class)
            ->getMock();

        /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */
        $app = $this->getMockBuilder(Application::class)
            ->setMethods(['make', 'instance', 'get'])
            ->getMock();
        Application::setInstance($app);

        $app->expects($this->once())
            ->method('make')
            ->with(Config::class)
            ->willReturn($config);

        $app->expects($this->once())
            ->method('instance')
            ->with('config', $config);

        $app->expects($this->atLeastOnce())
            ->method('get')
            ->with('path.config')
            ->willReturn(__DIR__ . '/../../../config');

        $config->expects($this->exactly(2))
            ->method('set')
            ->withAnyParameters();

        $config->expects($this->once())
            ->method('get')
            ->with(null)
            ->willReturn([]);

        $serviceProvider = new ConfigServiceProvider($app);
        $serviceProvider->register();
    }
}