1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Yoqut\Component\Sms\Model; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Yoqut\Component\Sms\Model\Sms; |
7
|
|
|
|
8
|
|
|
class SmsSpec extends ObjectBehavior |
9
|
|
|
{ |
10
|
|
|
public function getMatchers() |
11
|
|
|
{ |
12
|
|
|
return array( |
13
|
|
|
'haveMethod' => function($object, $method) { |
14
|
|
|
return method_exists($object, $method); |
15
|
|
|
} |
16
|
|
|
); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
function it_is_initializable() |
20
|
|
|
{ |
21
|
|
|
$this->shouldHaveType('Yoqut\Component\Sms\Model\Sms'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
function it_implements_Yoqut_sms_interface() |
25
|
|
|
{ |
26
|
|
|
$this->shouldImplement('Yoqut\Component\Sms\Model\SmsInterface'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
function it_has_no_id_by_default() |
30
|
|
|
{ |
31
|
|
|
$this->getId()->shouldReturn(null); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function its_id_is_immutable() |
35
|
|
|
{ |
36
|
|
|
$this->shouldNotHaveMethod('setId'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
function it_has_no_sender_by_default() |
40
|
|
|
{ |
41
|
|
|
$this->getSender()->shouldReturn(null); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function its_sender_is_mutable() |
45
|
|
|
{ |
46
|
|
|
$sender = 'sender'; |
47
|
|
|
$this->setSender($sender); |
48
|
|
|
$this->getSender()->shouldReturn($sender); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function it_has_no_recipient_by_default() |
52
|
|
|
{ |
53
|
|
|
$this->getRecipient()->shouldReturn(null); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
function its_recipient_is_mutable() |
57
|
|
|
{ |
58
|
|
|
$recipient = 'recipient'; |
59
|
|
|
$this->setRecipient($recipient); |
60
|
|
|
$this->getRecipient()->shouldReturn($recipient); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
function it_has_no_message_by_default() |
64
|
|
|
{ |
65
|
|
|
$this->getMessage()->shouldReturn(null); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
function its_message_is_mutable() |
69
|
|
|
{ |
70
|
|
|
$message = 'message'; |
71
|
|
|
$this->setMessage($message); |
72
|
|
|
$this->getMessage()->shouldReturn($message); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
function it_has_no_state_by_default() |
76
|
|
|
{ |
77
|
|
|
$this->getState()->shouldReturn(null); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
function its_state_is_mutable() |
81
|
|
|
{ |
82
|
|
|
$state = Sms::STATE_SENT; |
83
|
|
|
$this->setState($state); |
84
|
|
|
$this->getState()->shouldReturn($state); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
function it_throws_exception_if_state_is_invalid() |
88
|
|
|
{ |
89
|
|
|
$this |
90
|
|
|
->shouldThrow('\InvalidArgumentException') |
91
|
|
|
->duringSetState(-1); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
function it_has_creation_date_by_default() |
95
|
|
|
{ |
96
|
|
|
$this->getCreatedAt()->shouldHaveType('DateTime'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
function its_creation_date_is_mutable() |
100
|
|
|
{ |
101
|
|
|
$date = new \DateTime(); |
102
|
|
|
$this->setCreatedAt($date); |
103
|
|
|
$this->getCreatedAt()->shouldReturn($date); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
function it_has_no_updated_date_by_default() |
107
|
|
|
{ |
108
|
|
|
$this->getUpdatedAt()->shouldReturn(null); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
function its_updated_date_is_mutable() |
112
|
|
|
{ |
113
|
|
|
$date = new \DateTime(); |
114
|
|
|
$this->setUpdatedAt($date); |
115
|
|
|
$this->getUpdatedAt()->shouldReturn($date); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|