summaryrefslogtreecommitdiff
path: root/tests/units/Model/AuthenticationTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Model/AuthenticationTest.php')
-rw-r--r--tests/units/Model/AuthenticationTest.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/units/Model/AuthenticationTest.php b/tests/units/Model/AuthenticationTest.php
new file mode 100644
index 00000000..7ce81d8b
--- /dev/null
+++ b/tests/units/Model/AuthenticationTest.php
@@ -0,0 +1,39 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Model\User;
+use Model\Authentication;
+
+class AuthenticationTest extends Base
+{
+ public function testHasCaptcha()
+ {
+ $u = new User($this->container);
+ $a = new Authentication($this->container);
+
+ $this->assertFalse($a->hasCaptcha('not_found'));
+ $this->assertFalse($a->hasCaptcha('admin'));
+
+ $this->assertTrue($u->incrementFailedLogin('admin'));
+ $this->assertTrue($u->incrementFailedLogin('admin'));
+ $this->assertTrue($u->incrementFailedLogin('admin'));
+
+ $this->assertFalse($a->hasCaptcha('not_found'));
+ $this->assertTrue($a->hasCaptcha('admin'));
+ }
+
+ public function testHandleFailedLogin()
+ {
+ $u = new User($this->container);
+ $a = new Authentication($this->container);
+
+ $this->assertFalse($u->isLocked('admin'));
+
+ for ($i = 0; $i <= 6; $i++) {
+ $a->handleFailedLogin('admin');
+ }
+
+ $this->assertTrue($u->isLocked('admin'));
+ }
+}