diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-10 15:02:07 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2018-08-12 17:38:36 +0200 |
commit | d243090fea52b68a5ad5d55a5927ca95b5bf8bb1 (patch) | |
tree | 08c3810a9e32b0368a2518b0823d4fccaec98ce4 /tests | |
parent | f46e921b710b02d5a1f17f0dd076a5bf085ae735 (diff) |
config: allow renaming of config.default.php to config.php
Closes #444 (Problems after installation)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Config/ConfigServiceProviderTest.php | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php index c8be4b7d..998c0ba1 100644 --- a/tests/Unit/Config/ConfigServiceProviderTest.php +++ b/tests/Unit/Config/ConfigServiceProviderTest.php @@ -6,6 +6,7 @@ use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Config\ConfigServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; +use Exception; use PHPUnit_Framework_MockObject_MockObject; class ConfigServiceProviderTest extends ServiceProviderTest @@ -27,12 +28,15 @@ class ConfigServiceProviderTest extends ServiceProviderTest $this->setExpects($app, 'get', ['path.config'], __DIR__ . '/../../../config', $this->atLeastOnce()); $this->setExpects($config, 'set', null, null, $this->exactly(2)); - $this->setExpects($config, 'get', [null], []); + $config->expects($this->exactly(3)) + ->method('get') + ->with(null) + ->willReturnOnConsecutiveCalls([], [], ['lor' => 'em']); $configFile = __DIR__ . '/../../../config/config.php'; $configExists = file_exists($configFile); if (!$configExists) { - file_put_contents($configFile, '<?php return [];'); + file_put_contents($configFile, '<?php return ["lor"=>"em"];'); } $serviceProvider = new ConfigServiceProvider($app); @@ -42,4 +46,29 @@ class ConfigServiceProviderTest extends ServiceProviderTest unlink($configFile); } } + + /** + * @covers \Engelsystem\Config\ConfigServiceProvider::register() + */ + public function testRegisterException() + { + /** @var PHPUnit_Framework_MockObject_MockObject|Config $config */ + $config = $this->getMockBuilder(Config::class) + ->getMock(); + + $app = $this->getApp(['make', 'instance', 'get']); + Application::setInstance($app); + + $this->setExpects($app, 'make', [Config::class], $config); + $this->setExpects($app, 'instance', ['config', $config]); + $this->setExpects($app, 'get', ['path.config'], __DIR__ . '/not_existing', $this->atLeastOnce()); + + $this->setExpects($config, 'set', null, null, $this->never()); + $this->setExpects($config, 'get', [null], []); + + $this->expectException(Exception::class); + + $serviceProvider = new ConfigServiceProvider($app); + $serviceProvider->register(); + } } |