summaryrefslogtreecommitdiff
path: root/tests/units/Model/AuthenticationTest.php
blob: 7ce81d8b25a8038f013ef70fcdc89070c3c444d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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'));
    }
}