Code Duplication    Length = 59-61 lines in 2 locations

IdentityAccess/tests/Spec/Kreta/IdentityAccess/Application/DataTransformer/UserDTODataTransformerSpec.php 2 locations

@@ 41-99 (lines=59) @@
38
        $this->shouldHaveType(\BenGorUser\User\Application\DataTransformer\UserDTODataTransformer::class);
39
    }
40
41
    function it_transforms(
42
        User $user,
43
        \DateTimeImmutable $createdOn,
44
        \DateTimeImmutable $lastLogin,
45
        \DateTimeImmutable $updatedOn,
46
        FullName $fullName,
47
        Username $username,
48
        Image $image
49
    ) {
50
        $this->read()->shouldReturn([]);
51
52
        $this->write($user);
53
54
        $user->roles()->shouldBeCalled()->willReturn([new UserRole('ROLE_USER')]);
55
56
        $password = UserPassword::fromEncoded('encoded-password', 'user-password-salt');
57
58
        $user->id()->shouldBeCalled()->willReturn(new UserId('user-id'));
59
        $user->confirmationToken()->shouldBeCalled()->willReturn(null);
60
        $user->createdOn()->shouldBeCalled()->willReturn($createdOn);
61
        $user->email()->shouldBeCalled()->willReturn(new UserEmail('[email protected]'));
62
        $user->invitationToken()->shouldBeCalled()->willReturn(null);
63
        $user->lastLogin()->shouldBeCalled()->willReturn($lastLogin);
64
        $user->password()->shouldBeCalled()->willReturn($password);
65
        $user->rememberPasswordToken()->shouldBeCalled()->willReturn(null);
66
        $user->updatedOn()->shouldBeCalled()->willReturn($updatedOn);
67
68
        $user->username()->shouldBeCalled()->willReturn($username);
69
        $username->username()->shouldBeCalled()->willReturn('user11111');
70
71
        $user->fullName()->shouldBeCalled()->willReturn($fullName);
72
        $fullName->firstName()->shouldBeCalled()->willReturn('The user first name');
73
        $fullName->lastName()->shouldBeCalled()->willReturn('The user last name');
74
        $fullName->fullName()->shouldBeCalled()->willReturn('The user first name The user last name');
75
76
        $user->image()->shouldBeCalled()->willReturn($image);
77
        $imageName = new FileName('image-name.png');
78
        $image->name()->shouldBeCalled()->willReturn($imageName);
79
80
        $this->read()->shouldReturn([
81
            'id'                      => 'user-id',
82
            'confirmation_token'      => null,
83
            'created_on'              => $createdOn,
84
            'email'                   => '[email protected]',
85
            'invitation_token'        => null,
86
            'last_login'              => $lastLogin,
87
            'encoded_password'        => 'encoded-password',
88
            'salt'                    => 'user-password-salt',
89
            'remember_password_token' => null,
90
            'roles'                   => ['ROLE_USER'],
91
            'updated_on'              => $updatedOn,
92
            'user_id'                 => 'user-id',
93
            'user_name'               => 'user11111',
94
            'first_name'              => 'The user first name',
95
            'last_name'               => 'The user last name',
96
            'full_name'               => 'The user first name The user last name',
97
            'image'                   => '/image-name.png',
98
        ]);
99
    }
100
101
    function it_transforms_with_other_upload_destination(
102
        User $user,
@@ 101-161 (lines=61) @@
98
        ]);
99
    }
100
101
    function it_transforms_with_other_upload_destination(
102
        User $user,
103
        \DateTimeImmutable $createdOn,
104
        \DateTimeImmutable $lastLogin,
105
        \DateTimeImmutable $updatedOn,
106
        FullName $fullName,
107
        Username $username,
108
        Image $image
109
    ) {
110
        $this->beConstructedWith('/other-upload-destination');
111
112
        $this->read()->shouldReturn([]);
113
114
        $this->write($user);
115
116
        $user->roles()->shouldBeCalled()->willReturn([new UserRole('ROLE_USER')]);
117
118
        $password = UserPassword::fromEncoded('encoded-password', 'user-password-salt');
119
120
        $user->id()->shouldBeCalled()->willReturn(new UserId('user-id'));
121
        $user->confirmationToken()->shouldBeCalled()->willReturn(null);
122
        $user->createdOn()->shouldBeCalled()->willReturn($createdOn);
123
        $user->email()->shouldBeCalled()->willReturn(new UserEmail('[email protected]'));
124
        $user->invitationToken()->shouldBeCalled()->willReturn(null);
125
        $user->lastLogin()->shouldBeCalled()->willReturn($lastLogin);
126
        $user->password()->shouldBeCalled()->willReturn($password);
127
        $user->rememberPasswordToken()->shouldBeCalled()->willReturn(null);
128
        $user->updatedOn()->shouldBeCalled()->willReturn($updatedOn);
129
130
        $user->username()->shouldBeCalled()->willReturn($username);
131
        $username->username()->shouldBeCalled()->willReturn('user11111');
132
133
        $user->fullName()->shouldBeCalled()->willReturn($fullName);
134
        $fullName->firstName()->shouldBeCalled()->willReturn('The user first name');
135
        $fullName->lastName()->shouldBeCalled()->willReturn('The user last name');
136
        $fullName->fullName()->shouldBeCalled()->willReturn('The user first name The user last name');
137
138
        $user->image()->shouldBeCalled()->willReturn($image);
139
        $imageName = new FileName('image-name.png');
140
        $image->name()->shouldBeCalled()->willReturn($imageName);
141
142
        $this->read()->shouldReturn([
143
            'id'                      => 'user-id',
144
            'confirmation_token'      => null,
145
            'created_on'              => $createdOn,
146
            'email'                   => '[email protected]',
147
            'invitation_token'        => null,
148
            'last_login'              => $lastLogin,
149
            'encoded_password'        => 'encoded-password',
150
            'salt'                    => 'user-password-salt',
151
            'remember_password_token' => null,
152
            'roles'                   => ['ROLE_USER'],
153
            'updated_on'              => $updatedOn,
154
            'user_id'                 => 'user-id',
155
            'user_name'               => 'user11111',
156
            'first_name'              => 'The user first name',
157
            'last_name'               => 'The user last name',
158
            'full_name'               => 'The user first name The user last name',
159
            'image'                   => '/other-upload-destination/image-name.png',
160
        ]);
161
    }
162
}
163