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\Notifier\Domain\ReadModel\Inbox\Notification; |
16
|
|
|
|
17
|
|
|
use Kreta\Notifier\Domain\ReadModel\Inbox\Notification\Notification; |
18
|
|
|
use PhpSpec\ObjectBehavior; |
19
|
|
|
|
20
|
|
|
class NotificationSpec extends ObjectBehavior |
21
|
|
|
{ |
22
|
|
View Code Duplication |
function it_can_be_built() |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
$this->beConstructedWith('notification-id', 'user-id', 'The notification body', 638323200, 'unread'); |
25
|
|
|
$this->shouldHaveType(Notification::class); |
26
|
|
|
$this->shouldImplement(\JsonSerializable::class); |
27
|
|
|
$this->jsonSerialize()->shouldReturn([ |
28
|
|
|
'id' => 'notification-id', |
29
|
|
|
'user_id' => 'user-id', |
30
|
|
|
'body' => 'The notification body', |
31
|
|
|
'published_on' => 638323200, |
32
|
|
|
'status' => 'unread', |
33
|
|
|
'read_on' => null, |
34
|
|
|
]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
View Code Duplication |
function it_can_be_built_with_read_on() |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
$this->beConstructedWith('notification-id', 'user-id', 'The notification body', 638323200, 'read', 238343200); |
40
|
|
|
$this->shouldHaveType(Notification::class); |
41
|
|
|
$this->shouldImplement(\JsonSerializable::class); |
42
|
|
|
$this->jsonSerialize()->shouldReturn([ |
43
|
|
|
'id' => 'notification-id', |
44
|
|
|
'user_id' => 'user-id', |
45
|
|
|
'body' => 'The notification body', |
46
|
|
|
'published_on' => 638323200, |
47
|
|
|
'status' => 'read', |
48
|
|
|
'read_on' => 238343200, |
49
|
|
|
]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
function it_can_be_built_from_array() |
53
|
|
|
{ |
54
|
|
|
$this->beConstructedFromArray([ |
55
|
|
|
'id' => 'notification-id', |
56
|
|
|
'user_id' => 'user-id', |
57
|
|
|
'body' => 'The notification body', |
58
|
|
|
'published_on' => 638323200, |
59
|
|
|
'status' => 'unread', |
60
|
|
|
'read_on' => null, |
61
|
|
|
]); |
62
|
|
|
$this->jsonSerialize()->shouldReturn([ |
63
|
|
|
'id' => 'notification-id', |
64
|
|
|
'user_id' => 'user-id', |
65
|
|
|
'body' => 'The notification body', |
66
|
|
|
'published_on' => 638323200, |
67
|
|
|
'status' => 'unread', |
68
|
|
|
'read_on' => null, |
69
|
|
|
]); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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.