summaryrefslogtreecommitdiff
path: root/tests/Unit/Database/DatabaseServiceProviderTest.php
blob: 911af3990cc76b81bf7f6df9e066f1bd12a2e9cd (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',
            'database' => 'database',
            'username' => 'user',
            'password' => 'password',
        ], $this->atLeastOnce());
        $this->expectException(Exception::class);

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