summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-23 19:13:19 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-23 20:11:37 +0200
commit66038eda14d5d4e624b6636a6156570e3e940e49 (patch)
tree6e4b7557b7d91786ef47f22f7ddef85eed1dfb42 /tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php
parent590adffa9316b98544cb8d67b03b80e44ba9c8b7 (diff)
parent9d34f371cb9c5ab0d60bd3158678b9cc9da6cc80 (diff)
Merge branch 'twig-templates'
Diffstat (limited to 'tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php')
-rw-r--r--tests/Unit/Renderer/Twig/Extensions/AuthenticationTest.php56
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'));
+ }
+}