summaryrefslogtreecommitdiff
path: root/tests/Unit/Database
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-10-31 13:40:13 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-10-31 13:40:13 +0100
commit60fd72cd1a1e4e53b9af87e00a8c27687c6b5385 (patch)
treebcf250d05a49a848644af44f09fb897467e3ecb0 /tests/Unit/Database
parentfb05a38a963784716c105e7f214615ad13d2f272 (diff)
Added service providers
Diffstat (limited to 'tests/Unit/Database')
-rw-r--r--tests/Unit/Database/DatabaseServiceProviderTest.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/Unit/Database/DatabaseServiceProviderTest.php b/tests/Unit/Database/DatabaseServiceProviderTest.php
new file mode 100644
index 00000000..d0e3e164
--- /dev/null
+++ b/tests/Unit/Database/DatabaseServiceProviderTest.php
@@ -0,0 +1,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();
+ }
+}