1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Yoqut\Component\Sms\Model; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
|
7
|
|
|
class GatewaySpec extends ObjectBehavior |
8
|
|
|
{ |
9
|
|
|
public function getMatchers() |
10
|
|
|
{ |
11
|
|
|
return array( |
12
|
|
|
'haveMethod' => function($object, $method) { |
13
|
|
|
return method_exists($object, $method); |
14
|
|
|
} |
15
|
|
|
); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
function let( |
19
|
|
|
$host, |
20
|
|
|
$port, |
21
|
|
|
$interfaceVersion, |
22
|
|
|
$username, |
23
|
|
|
$password |
24
|
|
|
) { |
25
|
|
|
$this->beConstructedWith( |
26
|
|
|
$host, |
27
|
|
|
$port, |
28
|
|
|
$interfaceVersion, |
29
|
|
|
$username, |
30
|
|
|
$password |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function it_is_initializable() |
35
|
|
|
{ |
36
|
|
|
$this->shouldHaveType('Yoqut\Component\Sms\Model\Gateway'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
function it_implements_Yoqut_gateway_interface() |
40
|
|
|
{ |
41
|
|
|
$this->shouldImplement('Yoqut\Component\Sms\Model\GatewayInterface'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function it_has_no_id_by_default() |
45
|
|
|
{ |
46
|
|
|
$this->getId()->shouldReturn(null); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
function its_id_is_immutable() |
50
|
|
|
{ |
51
|
|
|
$this->shouldNotHaveMethod('setId'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
function it_has_no_name_by_default() |
55
|
|
|
{ |
56
|
|
|
$this->getName()->shouldReturn(null); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function its_name_is_mutable() |
60
|
|
|
{ |
61
|
|
|
$name = 'name'; |
62
|
|
|
$this->setName($name); |
63
|
|
|
$this->getName()->shouldReturn($name); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
function its_host_is_immutable() |
67
|
|
|
{ |
68
|
|
|
$this->shouldNotHaveMethod('setHost'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
function its_port_is_immutable() |
72
|
|
|
{ |
73
|
|
|
$this->shouldNotHaveMethod('setPort'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
function its_interface_version_is_immutable() |
77
|
|
|
{ |
78
|
|
|
$this->shouldNotHaveMethod('setInterfaceVersion'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
function its_username_is_immutable() |
82
|
|
|
{ |
83
|
|
|
$this->shouldNotHaveMethod('setUsername'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
function its_password_is_immutable() |
87
|
|
|
{ |
88
|
|
|
$this->shouldNotHaveMethod('setPassword'); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
function its_service_numbers_should_be_array() |
92
|
|
|
{ |
93
|
|
|
$this->getServiceNumbers()->shouldBeArray(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
function it_has_no_service_numbers_by_default() |
97
|
|
|
{ |
98
|
|
|
$this->getServiceNumbers()->shouldHaveCount(0); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
function its_service_numbers_are_immutable() |
102
|
|
|
{ |
103
|
|
|
$this->shouldNotHaveMethod('addServiceNumber'); |
104
|
|
|
$this->shouldNotHaveMethod('removeServiceNumber'); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
function its_prefix_codes_should_be_array() |
108
|
|
|
{ |
109
|
|
|
$this->getPrefixCodes()->shouldBeArray(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
function it_has_no_prefix_codes_by_default() |
113
|
|
|
{ |
114
|
|
|
$this->getPrefixCodes()->shouldHaveCount(0); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
function its_prefix_codes_are_immutable() |
118
|
|
|
{ |
119
|
|
|
$this->shouldNotHaveMethod('addPrefixCode'); |
120
|
|
|
$this->shouldNotHaveMethod('removePrefixCode'); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
function its_configs_should_be_array() |
124
|
|
|
{ |
125
|
|
|
$this->getConfigs()->shouldBeArray(); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
function it_has_configs_by_default() |
129
|
|
|
{ |
130
|
|
|
$this->getConfigs()->shouldNotHaveCount(0); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
function its_configs_are_immutable() |
134
|
|
|
{ |
135
|
|
|
$this->shouldNotHaveMethod('addConfig'); |
136
|
|
|
$this->shouldNotHaveMethod('removeConfig'); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|