diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-02 02:09:56 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-02 02:09:56 +0200 |
commit | 9e217d87c095170460a8580d5215ddf7cbe639f4 (patch) | |
tree | 3b426fe52e70ef0f1395edcb354f1be4788ca329 /tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php | |
parent | ac48332166ce28fcb1a2fc130c7f5adbc760e42d (diff) |
Template refactoring to use twig
Diffstat (limited to 'tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php')
-rw-r--r-- | tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php b/tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php new file mode 100644 index 00000000..0a72c0e7 --- /dev/null +++ b/tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php @@ -0,0 +1,56 @@ +<?php + +namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions; + +use Engelsystem\Renderer\Twig\Extensions\Authentication; + +class AuthenticationTest extends ExtensionTest +{ + /** + * @covers \Engelsystem\Renderer\Twig\Extensions\Authentication::getFunctions + */ + public function testGetFunctions() + { + $extension = new Authentication(); + $functions = $extension->getFunctions(); + + $this->assertExtensionExists('is_user', [$extension, 'isAuthenticated'], $functions); + $this->assertExtensionExists('is_guest', [$extension, 'isGuest'], $functions); + $this->assertExtensionExists('has_permission_to', [$extension, 'checkAuth'], $functions); + } + + /** + * @covers \Engelsystem\Renderer\Twig\Extensions\Authentication::isAuthenticated + * @covers \Engelsystem\Renderer\Twig\Extensions\Authentication::isGuest + */ + public function testIsAuthenticated() + { + global $user; + $user = []; + + $extension = new Authentication(); + + $this->assertFalse($extension->isAuthenticated()); + $this->assertTrue($extension->isGuest()); + + $user = ['lorem' => 'ipsum']; + $this->assertTrue($extension->isAuthenticated()); + $this->assertFalse($extension->isGuest()); + } + + /** + * @covers \Engelsystem\Renderer\Twig\Extensions\Authentication::checkAuth + */ + public function testCheckAuth() + { + global $privileges; + $privileges = []; + + $extension = new Authentication(); + + $this->assertFalse($extension->checkAuth('foo.bar')); + + $privileges = ['foo.bar']; + $this->assertTrue($extension->checkAuth('foo.bar')); + } +} |