Passed
Branch master (17d5a9)
by michael
08:14
created

U2fAuthenticationRequiredEventTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 5
1
<?php
2
3
/*
4
 * This file is part of the U2F Security bundle.
5
 *
6
 * (c) Michael Barbey <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mbarbey\U2fSecurityBundle\Tests\Event\Authentication;
13
14
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
15
use Mbarbey\U2fSecurityBundle\Model\User\U2fUser;
16
use Mbarbey\U2fSecurityBundle\Event\Authentication\U2fAuthenticationRequiredEvent;
17
18
class U2fAuthenticationRequiredEventTest extends TestCase
19
{
20
    private $event;
21
    private $user;
22
23
    public function setUp()
24
    {
25
        $this->user = $this->getMockForAbstractClass(U2fUser::class);
26
27
        $this->event = new U2fAuthenticationRequiredEvent($this->user);
28
    }
29
30
    public function testName()
31
    {
32
        $name = 'u2f.authentication.required';
33
34
        $this->assertEquals(U2fAuthenticationRequiredEvent::getName(), $name);
35
        $this->assertEquals($this->event->getName(), $name);
36
    }
37
38
    public function testUser()
39
    {
40
        $this->assertEquals($this->event->getUser(), $this->user);
41
    }
42
43
    public function testMustAuthenticate()
44
    {
45
        $this->assertTrue($this->event->mustAuthenticate());
46
    }
47
48
    public function testAbort()
49
    {
50
        $this->event->abort();
51
        $this->assertFalse($this->event->mustAuthenticate());
52
    }
53
}
54