diff options
Diffstat (limited to 'tests/Unit/HelpersTest.php')
-rw-r--r-- | tests/Unit/HelpersTest.php | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php index d9782888..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,39 @@ 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() + { + putenv('envTestVar=someContent'); + + $env = env('envTestVar'); + $this->assertEquals('someContent', $env); + + $env = env('someRandomEnvVarThatShouldNeverExist', 'someDefaultValue'); + $this->assertEquals('someDefaultValue', $env); + } + + /** * @covers \request */ public function testRequest() @@ -132,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) { |