1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Yproximite\Api\Message\User; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
|
7
|
|
|
use Yproximite\Api\Model\User\User; |
8
|
|
|
use Yproximite\Api\Message\User\UserPatchMessage; |
9
|
|
|
|
10
|
|
|
class UserPatchMessageSpec extends ObjectBehavior |
11
|
|
|
{ |
12
|
|
|
function it_is_initializable() |
13
|
|
|
{ |
14
|
|
|
$this->shouldHaveType(UserPatchMessage::class); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
View Code Duplication |
function it_should_build() |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
$this->setFirstName('Example'); |
20
|
|
|
$this->setLastName(''); |
21
|
|
|
$this->setEmail('[email protected]'); |
22
|
|
|
$this->setPlainPassword('12345'); |
23
|
|
|
$this->setPhone('+1 234 567 890'); |
24
|
|
|
$this->setDefaultLocale('en'); |
25
|
|
|
|
26
|
|
|
$data = [ |
27
|
|
|
'firstName' => 'Example', |
28
|
|
|
'lastName' => '', |
29
|
|
|
'email' => '[email protected]', |
30
|
|
|
'plainPassword' => '12345', |
31
|
|
|
'phone' => '+1 234 567 890', |
32
|
|
|
'defaultLocale' => 'en', |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
$this->build()->shouldReturn($data); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function it_should_create_from_user(User $user) |
39
|
|
|
{ |
40
|
|
|
$user->getId()->willReturn(1); |
41
|
|
|
$user->getFirstName()->willReturn('Example'); |
42
|
|
|
$user->getLastName()->willReturn(''); |
43
|
|
|
$user->getEmail()->willReturn('[email protected]'); |
44
|
|
|
$user->getCompanyId()->willReturn(2); |
45
|
|
|
|
46
|
|
|
$message = new UserPatchMessage(); |
47
|
|
|
$message->setId(1); |
48
|
|
|
$message->setFirstName('Example'); |
49
|
|
|
$message->setLastName(''); |
50
|
|
|
$message->setEmail('[email protected]'); |
51
|
|
|
$message->setCompanyId(2); |
52
|
|
|
|
53
|
|
|
$this::createFromUser($user)->shouldBeLike($message); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
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.