Completed
Push — master ( bbd2b1...f08c3b )
by Kamil
31:47 queued 09:37
created

UserSpec::it_has_encoder_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\User\Model;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\User\Model\UserInterface;
18
19
final class UserSpec extends ObjectBehavior
20
{
21
    function it_implements_user_interface(): void
22
    {
23
        $this->shouldImplement(UserInterface::class);
24
    }
25
26
    function its_not_verified_by_default(): void
27
    {
28
        $this->isVerified()->shouldReturn(false);
29
    }
30
31
    function its_verified_at_date_is_mutable(\DateTime $date): void
32
    {
33
        $this->setVerifiedAt($date);
34
35
        $this->getVerifiedAt()->shouldReturn($date);
36
    }
37
38
    function its_verified_when_verified_at_is_not_empty(\DateTime $date): void
39
    {
40
        $this->setVerifiedAt($date);
41
42
        $this->isVerified()->shouldReturn(true);
43
    }
44
45
    function it_has_no_password_requested_at_date_by_default(): void
46
    {
47
        $this->getPasswordRequestedAt()->shouldReturn(null);
48
    }
49
50
    function its_password_requested_at_date_is_mutable(): void
51
    {
52
        $date = new \DateTime();
53
        $this->setPasswordRequestedAt($date);
54
55
        $this->getPasswordRequestedAt()->shouldReturn($date);
56
    }
57
58
    function it_should_return_true_if_password_request_is_non_expired(): void
59
    {
60
        $passwordRequestedAt = new \DateTime('-1 hour');
61
        $this->setPasswordRequestedAt($passwordRequestedAt);
62
        $ttl = new \DateInterval('P1D');
63
64
        $this->isPasswordRequestNonExpired($ttl)->shouldReturn(true);
65
    }
66
67
    function it_should_return_false_if_password_request_is_expired(): void
68
    {
69
        $passwordRequestedAt = new \DateTime('-2 hour');
70
        $this->setPasswordRequestedAt($passwordRequestedAt);
71
        $ttl = new \DateInterval('PT1H');
72
73
        $this->isPasswordRequestNonExpired($ttl)->shouldReturn(false);
74
    }
75
76
    function it_has_email_and_email_canonical(): void
77
    {
78
        $this->setEmail('[email protected]');
79
        $this->setEmailCanonical('[email protected]');
80
81
        $this->getEmail()->shouldReturn('[email protected]');
82
        $this->getEmailCanonical()->shouldReturn('[email protected]');
83
    }
84
85
    function it_has_encoder_name()
86
    {
87
        $this->getEncoderName()->shouldReturn(null);
88
89
        $this->setEncoderName('argon2i');
90
        $this->getEncoderName()->shouldReturn('argon2i');
91
    }
92
}
93