summaryrefslogtreecommitdiff
path: root/tests/Unit/HelpersTest.php
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/HelpersTest.php
parent411ea5bb6d0ecf32e6c989a99fac120502db9fe9 (diff)
Added tests for base_path and config_path
Diffstat (limited to 'tests/Unit/HelpersTest.php')
-rw-r--r--tests/Unit/HelpersTest.php43
1 files changed, 41 insertions, 2 deletions
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)
{