blob: d0e3e1645c16fe65bfa696c15431f70b4a29f0ed (
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
|
<?php
namespace Engelsystem\Test\Database;
use Engelsystem\Application;
use Engelsystem\Config\Config;
use Engelsystem\Database\DatabaseServiceProvider;
use Exception;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;
class DatabaseServiceProviderTest extends TestCase
{
/**
* @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();
/** @var PHPUnit_Framework_MockObject_MockObject|Application $app */
$app = $this->getMockBuilder(Application::class)
->setMethods(['get'])
->getMock();
$app->expects($this->once())
->method('get')
->with('config')
->willReturn($config);
$config->expects($this->atLeastOnce())
->method('get')
->with('database')
->willReturn([
'host' => 'localhost',
'db' => 'database',
'user' => 'user',
'pw' => 'password',
]);
$serviceProvider = new DatabaseServiceProvider($app);
$this->expectException(Exception::class);
$serviceProvider->register();
}
}
|