Completed
Pull Request — master (#240)
by Beñat
04:01
created

UserSpec::it_edits_profile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
nc 1
nop 2
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Spec\Kreta\IdentityAccess\Domain\Model\User;
14
15
use BenGorUser\User\Domain\Model\User as BaseUser;
16
use BenGorUser\User\Domain\Model\UserEmail;
17
use BenGorUser\User\Domain\Model\UserId;
18
use BenGorUser\User\Domain\Model\UserPassword;
19
use BenGorUser\User\Domain\Model\UserRole;
20
use BenGorUser\User\Infrastructure\Security\DummyUserPasswordEncoder;
21
use Kreta\IdentityAccess\Domain\Model\User\FullName;
22
use Kreta\IdentityAccess\Domain\Model\User\User;
23
use Kreta\IdentityAccess\Domain\Model\User\Username;
24
use PhpSpec\ObjectBehavior;
25
26
class UserSpec extends ObjectBehavior
27
{
28
    function let()
29
    {
30
        $encoder = new DummyUserPasswordEncoder('encodedPassword');
31
32
        $this->beConstructedSignUp(
33
            new UserId(),
34
            new UserEmail('[email protected]'),
35
            UserPassword::fromPlain('strongpassword', $encoder),
36
            [new UserRole('ROLE_USER')]
37
        );
38
    }
39
40
    function it_is_initializable()
41
    {
42
        $this->shouldHaveType(User::class);
43
        $this->shouldHaveType(BaseUser::class);
44
    }
45
46
    function it_gets_username()
47
    {
48
        $this->username()->shouldReturnAnInstanceOf(Username::class);
49
    }
50
51
    function it_gets_full_name()
52
    {
53
        $this->fullName()->shouldReturn(null);
54
    }
55
56
    function it_edits_profile(
57
        Username $username,
58
        FullName $fullName
59
    ) {
60
        $email = new UserEmail('[email protected]');
61
62
        $this->fullName()->shouldReturn(null);
63
64
        $this->editProfile($email, $username, $fullName);
65
66
        $fullName->fullName()->shouldBeCalled()->willReturn('Kreta name');
67
68
        $this->fullName()->shouldReturn($fullName);
69
        $this->username()->shouldReturn($username);
70
    }
71
}
72