summaryrefslogtreecommitdiff
path: root/tests/Unit/Config
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Config')
-rw-r--r--tests/Unit/Config/ConfigServiceProviderTest.php38
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php
index 2e37d0da..925854be 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
@@ -32,12 +33,15 @@ class ConfigServiceProviderTest extends ServiceProviderTest
);
$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);
@@ -47,4 +51,34 @@ 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);
+ $app->expects($this->exactly(2))
+ ->method('instance')
+ ->withConsecutive(
+ [Config::class, $config],
+ ['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();
+ }
}