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

namespace Engelsystem\Test\Unit\Database;

use Engelsystem\Config\Config;
use Engelsystem\Database\DatabaseServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest;
use Exception;
use PHPUnit_Framework_MockObject_MockObject;

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

        $app = $this->getApp(['get']);

        $this->setExpects($app, 'get', ['config'], $config);
        $this->setExpects($config, 'get', ['database'], [
            'host' => 'localhost',
            'db'   => 'database',
            'user' => 'user',
            'pw'   => 'password',
        ], $this->atLeastOnce());
        $this->expectException(Exception::class);

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