summaryrefslogtreecommitdiff
path: root/tests/Unit/Config/ConfigServiceProviderTest.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-11-28 15:43:51 +0100
committerGitHub <noreply@github.com>2017-11-28 15:43:51 +0100
commit599f2fd264bfc7b1b6826fe206442806e317340f (patch)
tree50cf84d7d07d11bd65b45c2c17f37632f6cd8eff /tests/Unit/Config/ConfigServiceProviderTest.php
parenta5fc5bd0979e8de1fce8a8addd351a6e7bd6aeb8 (diff)
parenteda7f7788ea8012bd8be46405c56a666c11f3fa5 (diff)
Merge pull request #365 from engelsystem/feature-igel-rewrite
Feature igel rewrite
Diffstat (limited to 'tests/Unit/Config/ConfigServiceProviderTest.php')
-rw-r--r--tests/Unit/Config/ConfigServiceProviderTest.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php
new file mode 100644
index 00000000..c8be4b7d
--- /dev/null
+++ b/tests/Unit/Config/ConfigServiceProviderTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Config;
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Config\ConfigServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject;
+
+class ConfigServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Config\ConfigServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @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__ . '/../../../config', $this->atLeastOnce());
+
+ $this->setExpects($config, 'set', null, null, $this->exactly(2));
+ $this->setExpects($config, 'get', [null], []);
+
+ $configFile = __DIR__ . '/../../../config/config.php';
+ $configExists = file_exists($configFile);
+ if (!$configExists) {
+ file_put_contents($configFile, '<?php return [];');
+ }
+
+ $serviceProvider = new ConfigServiceProvider($app);
+ $serviceProvider->register();
+
+ if (!$configExists) {
+ unlink($configFile);
+ }
+ }
+}