diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2017-10-31 19:26:48 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2017-10-31 19:26:48 +0100 |
commit | e55d5c7c15411eb58dd99113d94ee8ba55fd414a (patch) | |
tree | a7b0fa2a3769c41f9319792e1d4c4a4a65d2292b /tests/Feature/Database | |
parent | 8c703e12029c2170ced5cafe4c91e9fd5f8414d9 (diff) |
Added database tests
Diffstat (limited to 'tests/Feature/Database')
-rw-r--r-- | tests/Feature/Database/DatabaseServiceProviderTest.php (renamed from tests/Feature/Database/DatabaseServiceProviderConnectionTest.php) | 21 | ||||
-rw-r--r-- | tests/Feature/Database/DatabaseTest.php | 25 |
2 files changed, 29 insertions, 17 deletions
diff --git a/tests/Feature/Database/DatabaseServiceProviderConnectionTest.php b/tests/Feature/Database/DatabaseServiceProviderTest.php index 636fba2e..d5fdd108 100644 --- a/tests/Feature/Database/DatabaseServiceProviderConnectionTest.php +++ b/tests/Feature/Database/DatabaseServiceProviderTest.php @@ -5,21 +5,20 @@ namespace Engelsystem\Test\Feature\Database; use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Database\DatabaseServiceProvider; -use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit_Framework_MockObject_MockObject as MockObject; -class DatabaseServiceProviderConnectionTest extends TestCase +class DatabaseServiceProviderTest extends DatabaseTest { /** * @covers \Engelsystem\Database\DatabaseServiceProvider::register() */ public function testRegister() { - /** @var PHPUnit_Framework_MockObject_MockObject|Config $config */ + /** @var MockObject|Config $config */ $config = $this->getMockBuilder(Config::class) ->getMock(); - /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */ + /** @var MockObject|Application $app */ $app = $this->getMockBuilder(Application::class) ->setMethods(['get']) ->getMock(); @@ -38,16 +37,4 @@ class DatabaseServiceProviderConnectionTest extends TestCase $serviceProvider = new DatabaseServiceProvider($app); $serviceProvider->register(); } - - private function getDbConfig() - { - $configValues = require __DIR__ . '/../../../config/config.default.php'; - $configFile = __DIR__ . '/../../../config/config.php'; - - if (file_exists($configFile)) { - $configValues = array_replace_recursive($configValues, require $configFile); - } - - return $configValues['database']; - } } diff --git a/tests/Feature/Database/DatabaseTest.php b/tests/Feature/Database/DatabaseTest.php new file mode 100644 index 00000000..11df6779 --- /dev/null +++ b/tests/Feature/Database/DatabaseTest.php @@ -0,0 +1,25 @@ +<?php + +namespace Engelsystem\Test\Feature\Database; + +use PHPUnit\Framework\TestCase; + +abstract class DatabaseTest extends TestCase +{ + /** + * Returns the database config + * + * @return string[] + */ + protected function getDbConfig() + { + $configValues = require __DIR__ . '/../../../config/config.default.php'; + $configFile = __DIR__ . '/../../../config/config.php'; + + if (file_exists($configFile)) { + $configValues = array_replace_recursive($configValues, require $configFile); + } + + return $configValues['database']; + } +} |