diff options
author | msquare <msquare@notrademark.de> | 2017-11-12 13:25:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-12 13:25:56 +0100 |
commit | ebc973bf221bfbde327868975221e62704e4cb99 (patch) | |
tree | 9011a160f3d6f9cae37fc02836e7d6e8c25242ca /tests/Unit/HelpersTest.php | |
parent | 801c17aa6cef91be988a25a90442be8d2078a70d (diff) | |
parent | ad948bdd3201e922b626a736b0122533bdd37cae (diff) |
Merge pull request #349 from MyIgel/master
Changed container to Illuminate/Container and added service providers
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) { |