From 60fd72cd1a1e4e53b9af87e00a8c27687c6b5385 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 31 Oct 2017 13:40:13 +0100 Subject: Added service providers --- .../DatabaseServiceProviderConnectionTest.php | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/Feature/Database/DatabaseServiceProviderConnectionTest.php (limited to 'tests/Feature/Database/DatabaseServiceProviderConnectionTest.php') diff --git a/tests/Feature/Database/DatabaseServiceProviderConnectionTest.php b/tests/Feature/Database/DatabaseServiceProviderConnectionTest.php new file mode 100644 index 00000000..dd1ce729 --- /dev/null +++ b/tests/Feature/Database/DatabaseServiceProviderConnectionTest.php @@ -0,0 +1,53 @@ +getMockBuilder(Config::class) + ->getMock(); + + /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */ + $app = $this->getMockBuilder(Application::class) + ->setMethods(['get']) + ->getMock(); + Application::setInstance($app); + + $app->expects($this->once()) + ->method('get') + ->with('config') + ->willReturn($config); + + $config->expects($this->atLeastOnce()) + ->method('get') + ->with('database') + ->willReturn($this->getDbConfig()); + + $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']; + } +} -- cgit v1.2.3-54-g00ecf