2017-10-31 13:40:13 +01:00
|
|
|
<?php
|
|
|
|
|
2017-10-31 14:23:23 +01:00
|
|
|
namespace Engelsystem\Test\Unit\Database;
|
2017-10-31 13:40:13 +01:00
|
|
|
|
|
|
|
use Engelsystem\Config\Config;
|
|
|
|
use Engelsystem\Database\DatabaseServiceProvider;
|
2017-10-31 14:15:19 +01:00
|
|
|
use Engelsystem\Test\Unit\ServiceProviderTest;
|
2017-10-31 13:40:13 +01:00
|
|
|
use Exception;
|
|
|
|
use PHPUnit_Framework_MockObject_MockObject;
|
|
|
|
|
2017-10-31 14:15:19 +01:00
|
|
|
class DatabaseServiceProviderTest extends ServiceProviderTest
|
2017-10-31 13:40:13 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @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();
|
|
|
|
|
2017-10-31 14:15:19 +01:00
|
|
|
$app = $this->getApp(['get']);
|
2017-10-31 13:40:13 +01:00
|
|
|
|
2017-10-31 14:15:19 +01:00
|
|
|
$this->setExpects($app, 'get', ['config'], $config);
|
|
|
|
$this->setExpects($config, 'get', ['database'], [
|
2018-01-14 01:48:50 +01:00
|
|
|
'host' => 'localhost',
|
|
|
|
'database' => 'database',
|
|
|
|
'username' => 'user',
|
|
|
|
'password' => 'password',
|
2017-10-31 14:15:19 +01:00
|
|
|
], $this->atLeastOnce());
|
2017-10-31 13:40:13 +01:00
|
|
|
$this->expectException(Exception::class);
|
|
|
|
|
2017-10-31 14:15:19 +01:00
|
|
|
$serviceProvider = new DatabaseServiceProvider($app);
|
2017-10-31 13:40:13 +01:00
|
|
|
$serviceProvider->register();
|
|
|
|
}
|
|
|
|
}
|