summaryrefslogtreecommitdiff
path: root/tests/Feature/Database/DatabaseServiceProviderTest.php
blob: d5fdd10817c5c9a08912fa4f255300d45e71cbc2 (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
<?php

namespace Engelsystem\Test\Feature\Database;

use Engelsystem\Application;
use Engelsystem\Config\Config;
use Engelsystem\Database\DatabaseServiceProvider;
use PHPUnit_Framework_MockObject_MockObject as MockObject;

class DatabaseServiceProviderTest extends DatabaseTest
{
    /**
     * @covers \Engelsystem\Database\DatabaseServiceProvider::register()
     */
    public function testRegister()
    {
        /** @var MockObject|Config $config */
        $config = $this->getMockBuilder(Config::class)
            ->getMock();

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

        $app->expects($this->once())
            ->method('get')
            ->with('config')
            ->willReturn($config);

        $config->expects($this->atLeastOnce())
            ->method('get')
            ->with('database')
            ->willReturn($this->getDbConfig());

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