Completed
Push — master ( 633b6b...4d2598 )
by Beñat
10s
created

UserPublicDTODataTransformerSpec::it_transforms()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 30

Duplication

Lines 39
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 39
loc 39
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 30
nc 1
nop 7
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
declare(strict_types=1);
14
15
namespace Spec\Kreta\IdentityAccess\Application\DataTransformer;
16
17
use BenGorFile\File\Domain\Model\FileName;
18
use BenGorUser\User\Application\DataTransformer\UserDataTransformer;
19
use BenGorUser\User\Domain\Model\UserEmail;
20
use BenGorUser\User\Domain\Model\UserId;
21
use Kreta\IdentityAccess\Application\DataTransformer\UserPublicDTODataTransformer;
22
use Kreta\IdentityAccess\Domain\Model\User\FullName;
23
use Kreta\IdentityAccess\Domain\Model\User\Image;
24
use Kreta\IdentityAccess\Domain\Model\User\User;
25
use Kreta\IdentityAccess\Domain\Model\User\Username;
26
use PhpSpec\ObjectBehavior;
27
28
class UserPublicDTODataTransformerSpec extends ObjectBehavior
29
{
30
    function it_is_initializable()
31
    {
32
        $this->shouldHaveType(UserPublicDTODataTransformer::class);
33
    }
34
35
    function it_implements_user_data_transformer()
36
    {
37
        $this->shouldImplement(UserDataTransformer::class);
38
    }
39
40 View Code Duplication
    function it_transforms(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
        User $user,
42
        \DateTimeImmutable $createdOn,
0 ignored issues
show
Unused Code introduced by
The parameter $createdOn is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
        \DateTimeImmutable $lastLogin,
0 ignored issues
show
Unused Code introduced by
The parameter $lastLogin is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
        \DateTimeImmutable $updatedOn,
0 ignored issues
show
Unused Code introduced by
The parameter $updatedOn is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
        FullName $fullName,
46
        Username $username,
47
        Image $image
48
    ) {
49
        $this->read()->shouldReturn([]);
50
51
        $this->write($user);
52
53
        $user->id()->shouldBeCalled()->willReturn(new UserId('user-id'));
54
        $user->email()->shouldBeCalled()->willReturn(new UserEmail('[email protected]'));
55
56
        $user->username()->shouldBeCalled()->willReturn($username);
57
        $username->username()->shouldBeCalled()->willReturn('user11111');
58
59
        $user->fullName()->shouldBeCalled()->willReturn($fullName);
60
        $fullName->firstName()->shouldBeCalled()->willReturn('The user first name');
61
        $fullName->lastName()->shouldBeCalled()->willReturn('The user last name');
62
        $fullName->fullName()->shouldBeCalled()->willReturn('The user first name The user last name');
63
64
        $user->image()->shouldBeCalled()->willReturn($image);
65
        $imageName = new FileName('image-name.png');
66
        $image->name()->shouldBeCalled()->willReturn($imageName);
67
68
        $this->read()->shouldReturn([
69
            'id'                      => 'user-id',
70
            'user_id'                 => 'user-id',
71
            'email'                   => '[email protected]',
72
            'first_name'              => 'The user first name',
73
            'full_name'               => 'The user first name The user last name',
74
            'last_name'               => 'The user last name',
75
            'image'                   => '/image-name.png',
76
            'user_name'               => 'user11111',
77
        ]);
78
    }
79
80 View Code Duplication
    function it_transforms_with_other_upload_destination(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
        User $user,
82
        \DateTimeImmutable $createdOn,
0 ignored issues
show
Unused Code introduced by
The parameter $createdOn is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
83
        \DateTimeImmutable $lastLogin,
0 ignored issues
show
Unused Code introduced by
The parameter $lastLogin is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
84
        \DateTimeImmutable $updatedOn,
0 ignored issues
show
Unused Code introduced by
The parameter $updatedOn is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
        FullName $fullName,
86
        Username $username,
87
        Image $image
88
    ) {
89
        $this->beConstructedWith('/other-upload-destination');
90
91
        $this->read()->shouldReturn([]);
92
93
        $this->write($user);
94
95
        $user->id()->shouldBeCalled()->willReturn(new UserId('user-id'));
96
        $user->email()->shouldBeCalled()->willReturn(new UserEmail('[email protected]'));
97
98
        $user->username()->shouldBeCalled()->willReturn($username);
99
        $username->username()->shouldBeCalled()->willReturn('user11111');
100
101
        $user->fullName()->shouldBeCalled()->willReturn($fullName);
102
        $fullName->firstName()->shouldBeCalled()->willReturn('The user first name');
103
        $fullName->lastName()->shouldBeCalled()->willReturn('The user last name');
104
        $fullName->fullName()->shouldBeCalled()->willReturn('The user first name The user last name');
105
106
        $user->image()->shouldBeCalled()->willReturn($image);
107
        $imageName = new FileName('image-name.png');
108
        $image->name()->shouldBeCalled()->willReturn($imageName);
109
110
        $this->read()->shouldReturn([
111
            'id'                      => 'user-id',
112
            'user_id'                 => 'user-id',
113
            'email'                   => '[email protected]',
114
            'first_name'              => 'The user first name',
115
            'full_name'               => 'The user first name The user last name',
116
            'last_name'               => 'The user last name',
117
            'image'                   => '/other-upload-destination/image-name.png',
118
            'user_name'               => 'user11111',
119
        ]);
120
    }
121
}
122