summaryrefslogtreecommitdiff
path: root/tests/Unit
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-10-31 14:23:23 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-10-31 14:30:37 +0100
commite15e86362585f5d00d118653232584ed0920e533 (patch)
tree0e3e4750e91b3deab2173334e2b7e9b05742d3fc /tests/Unit
parent411ea5bb6d0ecf32e6c989a99fac120502db9fe9 (diff)
Added tests for base_path and config_path
Diffstat (limited to 'tests/Unit')
-rw-r--r--tests/Unit/ApplicationTest.php2
-rw-r--r--tests/Unit/Config/ConfigServiceProviderTest.php2
-rw-r--r--tests/Unit/Config/ConfigTest.php2
-rw-r--r--tests/Unit/Database/DatabaseServiceProviderTest.php2
-rw-r--r--tests/Unit/Exceptions/ExceptionsServiceProviderTest.php2
-rw-r--r--tests/Unit/HelpersTest.php43
-rw-r--r--tests/Unit/Logger/LoggerServiceProviderTest.php2
-rw-r--r--tests/Unit/Renderer/HtmlEngineTest.php2
-rw-r--r--tests/Unit/Renderer/RendererServiceProviderTest.php2
-rw-r--r--tests/Unit/Renderer/RendererTest.php6
-rw-r--r--tests/Unit/Routing/RoutingServiceProviderTest.php2
-rw-r--r--tests/Unit/Routing/UrlGeneratorTest.php2
12 files changed, 56 insertions, 13 deletions
diff --git a/tests/Unit/ApplicationTest.php b/tests/Unit/ApplicationTest.php
index 78310134..f58483ea 100644
--- a/tests/Unit/ApplicationTest.php
+++ b/tests/Unit/ApplicationTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Config;
+namespace Engelsystem\Test\Unit;
use Engelsystem\Application;
use Engelsystem\Config\Config;
diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php
index 96ac8704..ab6fa67f 100644
--- a/tests/Unit/Config/ConfigServiceProviderTest.php
+++ b/tests/Unit/Config/ConfigServiceProviderTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Config;
+namespace Engelsystem\Test\Unit\Config;
use Engelsystem\Application;
use Engelsystem\Config\Config;
diff --git a/tests/Unit/Config/ConfigTest.php b/tests/Unit/Config/ConfigTest.php
index ce11ebd6..043599fd 100644
--- a/tests/Unit/Config/ConfigTest.php
+++ b/tests/Unit/Config/ConfigTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Config;
+namespace Engelsystem\Test\Unit\Config;
use Engelsystem\Config\Config;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Unit/Database/DatabaseServiceProviderTest.php b/tests/Unit/Database/DatabaseServiceProviderTest.php
index d61f5ae7..61848c35 100644
--- a/tests/Unit/Database/DatabaseServiceProviderTest.php
+++ b/tests/Unit/Database/DatabaseServiceProviderTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Database;
+namespace Engelsystem\Test\Unit\Database;
use Engelsystem\Config\Config;
use Engelsystem\Database\DatabaseServiceProvider;
diff --git a/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php
index fc48d39e..9c943d52 100644
--- a/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php
+++ b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Exceptions;
+namespace Engelsystem\Test\Unit\Exceptions;
use Engelsystem\Exceptions\ExceptionsServiceProvider;
use Engelsystem\Exceptions\Handler as ExceptionHandler;
diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php
index 9ec824af..0a8d5d2b 100644
--- a/tests/Unit/HelpersTest.php
+++ b/tests/Unit/HelpersTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Config;
+namespace Engelsystem\Test\Unit;
use Engelsystem\Application;
use Engelsystem\Config\Config;
@@ -9,6 +9,7 @@ use Engelsystem\Http\Request;
use Engelsystem\Renderer\Renderer;
use Engelsystem\Routing\UrlGenerator;
use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Symfony\Component\HttpFoundation\Session\Session;
class HelpersTest extends TestCase
@@ -29,6 +30,25 @@ class HelpersTest extends TestCase
}
/**
+ * @covers \base_path()
+ */
+ public function testBasePath()
+ {
+ /** @var MockObject|Application $app */
+ $app = $this->getMockBuilder(Container::class)
+ ->getMock();
+ Application::setInstance($app);
+
+ $app->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('path')
+ ->willReturn('/foo/bar');
+
+ $this->assertEquals('/foo/bar', base_path());
+ $this->assertEquals('/foo/bar/bla-foo.conf', base_path('bla-foo.conf'));
+ }
+
+ /**
* @covers \config
*/
public function testConfig()
@@ -54,6 +74,25 @@ class HelpersTest extends TestCase
}
/**
+ * @covers \config_path()
+ */
+ public function testConfigPath()
+ {
+ /** @var MockObject|Application $app */
+ $app = $this->getMockBuilder(Container::class)
+ ->getMock();
+ Application::setInstance($app);
+
+ $app->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('path.config')
+ ->willReturn('/foo/conf');
+
+ $this->assertEquals('/foo/conf', config_path());
+ $this->assertEquals('/foo/conf/bar.php', config_path('bar.php'));
+ }
+
+ /**
* @covers \env
*/
public function testEnv()
@@ -146,7 +185,7 @@ class HelpersTest extends TestCase
/**
* @param string $alias
* @param object $object
- * @return Application|\PHPUnit_Framework_MockObject_MockObject
+ * @return Application|MockObject
*/
protected function getAppMock($alias, $object)
{
diff --git a/tests/Unit/Logger/LoggerServiceProviderTest.php b/tests/Unit/Logger/LoggerServiceProviderTest.php
index 66f63cf4..cef95d5b 100644
--- a/tests/Unit/Logger/LoggerServiceProviderTest.php
+++ b/tests/Unit/Logger/LoggerServiceProviderTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Logger;
+namespace Engelsystem\Test\Unit\Logger;
use Engelsystem\Logger\EngelsystemLogger;
use Engelsystem\Logger\LoggerServiceProvider;
diff --git a/tests/Unit/Renderer/HtmlEngineTest.php b/tests/Unit/Renderer/HtmlEngineTest.php
index 0b317b72..8c262932 100644
--- a/tests/Unit/Renderer/HtmlEngineTest.php
+++ b/tests/Unit/Renderer/HtmlEngineTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Config;
+namespace Engelsystem\Test\Unit\Renderer;
use Engelsystem\Renderer\HtmlEngine;
use PHPUnit\Framework\TestCase;
diff --git a/tests/Unit/Renderer/RendererServiceProviderTest.php b/tests/Unit/Renderer/RendererServiceProviderTest.php
index f9044d8b..3826da7e 100644
--- a/tests/Unit/Renderer/RendererServiceProviderTest.php
+++ b/tests/Unit/Renderer/RendererServiceProviderTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Logger;
+namespace Engelsystem\Test\Unit\Renderer;
use Engelsystem\Renderer\EngineInterface;
use Engelsystem\Renderer\HtmlEngine;
diff --git a/tests/Unit/Renderer/RendererTest.php b/tests/Unit/Renderer/RendererTest.php
index b0238078..969ced7f 100644
--- a/tests/Unit/Renderer/RendererTest.php
+++ b/tests/Unit/Renderer/RendererTest.php
@@ -1,10 +1,11 @@
<?php
-namespace Engelsystem\Test\Config;
+namespace Engelsystem\Test\Unit\Renderer;
use Engelsystem\Renderer\EngineInterface;
use Engelsystem\Renderer\Renderer;
use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
class RendererTest extends TestCase
@@ -13,6 +14,7 @@ class RendererTest extends TestCase
{
$renderer = new Renderer();
+ /** @var MockObject|EngineInterface $nullRenderer */
$nullRenderer = $this->getMockForAbstractClass(EngineInterface::class);
$nullRenderer->expects($this->atLeastOnce())
@@ -20,6 +22,7 @@ class RendererTest extends TestCase
->willReturn(false);
$renderer->addRenderer($nullRenderer);
+ /** @var MockObject|EngineInterface $mockRenderer */
$mockRenderer = $this->getMockForAbstractClass(EngineInterface::class);
$mockRenderer->expects($this->atLeastOnce())
@@ -42,6 +45,7 @@ class RendererTest extends TestCase
{
$renderer = new Renderer();
+ /** @var MockObject|LoggerInterface $loggerMock */
$loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
$loggerMock
->expects($this->once())
diff --git a/tests/Unit/Routing/RoutingServiceProviderTest.php b/tests/Unit/Routing/RoutingServiceProviderTest.php
index bb2a1d65..dd9441eb 100644
--- a/tests/Unit/Routing/RoutingServiceProviderTest.php
+++ b/tests/Unit/Routing/RoutingServiceProviderTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Routing;
+namespace Engelsystem\Test\Unit\Routing;
use Engelsystem\Routing\RoutingServiceProvider;
use Engelsystem\Routing\UrlGenerator;
diff --git a/tests/Unit/Routing/UrlGeneratorTest.php b/tests/Unit/Routing/UrlGeneratorTest.php
index fc23520a..6da59a4f 100644
--- a/tests/Unit/Routing/UrlGeneratorTest.php
+++ b/tests/Unit/Routing/UrlGeneratorTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Engelsystem\Test\Config;
+namespace Engelsystem\Test\Unit\Routing;
use Engelsystem\Application;
use Engelsystem\Container\Container;