13
13
use PHPUnit \Framework \TestCase ;
14
14
15
15
/**
16
- * Typed Array Test
16
+ * Typed Array Test.
17
17
*/
18
18
class TypedArrayTest extends TestCase
19
19
{
20
20
/**
21
21
* Provide allowed types.
22
- *
22
+ *
23
23
* @return array
24
24
*/
25
- function allowedTypeProvider ()
25
+ public function allowedTypeProvider ()
26
26
{
27
27
return [
28
28
['array ' ],
@@ -34,7 +34,7 @@ function allowedTypeProvider()
34
34
['string ' ],
35
35
];
36
36
}
37
-
37
+
38
38
/**
39
39
* Test new instance.
40
40
*
@@ -44,7 +44,7 @@ public function testCreateInstance($type)
44
44
{
45
45
$ this ->assertInstanceOf (TypedArray::class, (new TypedArray ($ type )));
46
46
}
47
-
47
+
48
48
/**
49
49
* Test new instance with not allowed type.
50
50
*
@@ -54,26 +54,27 @@ public function testCreateInstanceWithNotAllowedType()
54
54
{
55
55
$ this ->assertInstanceOf (TypedArray::class, (new TypedArray ('notAllowedType ' )));
56
56
}
57
-
58
-
57
+
59
58
/**
60
59
* Provide arrays of right typed values.
61
- *
60
+ *
62
61
* @return array
63
62
*/
64
- function rightTypedArrayProvider ()
63
+ public function rightTypedArrayProvider ()
65
64
{
66
65
return [
67
- ['array ' , [[1 ],[2 ]]],
66
+ ['array ' , [[1 ], [2 ]]],
68
67
['bool ' , [true , false ]],
69
- ['callable ' , [function (){}, function (){}]],
68
+ ['callable ' , [function () {
69
+ }, function () {
70
+ }]],
70
71
['float ' , [1.1 , 2.2 ]],
71
72
['int ' , [1 , 2 ]],
72
- ['object ' , [(object )['name ' => 'foo ' ], (object )['name ' => 'bar ' ]]],
73
+ ['object ' , [(object ) ['name ' => 'foo ' ], (object ) ['name ' => 'bar ' ]]],
73
74
['string ' , ['a ' , 'b ' ]],
74
75
];
75
76
}
76
-
77
+
77
78
/**
78
79
* Test new instance passing right typed array to constructor.
79
80
*
@@ -83,67 +84,77 @@ public function testCreateInstanceWithRightTypedArray($type, $array)
83
84
{
84
85
$ this ->assertInstanceOf (TypedArray::class, (new TypedArray ($ type , $ array )));
85
86
}
86
-
87
+
87
88
/**
88
89
* Provide arrays of wrong typed values.
89
- *
90
+ *
90
91
* @return array
91
92
*/
92
- function wrongTypedArrayProvider ()
93
+ public function wrongTypedArrayProvider ()
93
94
{
94
95
return [
95
96
['array ' , [true , false ]],
96
- ['array ' , [function (){}, function (){}]],
97
+ ['array ' , [function () {
98
+ }, function () {
99
+ }]],
97
100
['array ' , [1.1 , 2.2 ]],
98
101
['array ' , [1 , 2 ]],
99
- ['array ' , [(object )['name ' => 'foo ' ], (object )['name ' => 'bar ' ]]],
102
+ ['array ' , [(object ) ['name ' => 'foo ' ], (object ) ['name ' => 'bar ' ]]],
100
103
['array ' , ['a ' , 'b ' ]],
101
-
102
- ['bool ' , [[1 ],[2 ]]],
103
- ['bool ' , [function (){}, function (){}]],
104
+
105
+ ['bool ' , [[1 ], [2 ]]],
106
+ ['bool ' , [function () {
107
+ }, function () {
108
+ }]],
104
109
['bool ' , [1.1 , 2.2 ]],
105
110
['bool ' , [1 , 2 ]],
106
- ['bool ' , [(object )['name ' => 'foo ' ], (object )['name ' => 'bar ' ]]],
111
+ ['bool ' , [(object ) ['name ' => 'foo ' ], (object ) ['name ' => 'bar ' ]]],
107
112
['bool ' , ['a ' , 'b ' ]],
108
-
109
- ['callable ' , [[1 ],[2 ]]],
113
+
114
+ ['callable ' , [[1 ], [2 ]]],
110
115
['callable ' , [true , false ]],
111
116
['callable ' , [1.1 , 2.2 ]],
112
117
['callable ' , [1 , 2 ]],
113
- ['callable ' , [(object )['name ' => 'foo ' ], (object )['name ' => 'bar ' ]]],
114
- ['callable ' , ['a ' , 'b ' ]],
115
-
116
- ['float ' , [[1 ],[2 ]]],
118
+ ['callable ' , [(object ) ['name ' => 'foo ' ], (object ) ['name ' => 'bar ' ]]],
119
+ ['callable ' , ['a ' , 'b ' ]],
120
+
121
+ ['float ' , [[1 ], [2 ]]],
117
122
['float ' , [true , false ]],
118
- ['float ' , [function (){}, function (){}]],
123
+ ['float ' , [function () {
124
+ }, function () {
125
+ }]],
119
126
['float ' , [1 , 2 ]],
120
- ['float ' , [(object )['name ' => 'foo ' ], (object )['name ' => 'bar ' ]]],
127
+ ['float ' , [(object ) ['name ' => 'foo ' ], (object ) ['name ' => 'bar ' ]]],
121
128
['float ' , ['a ' , 'b ' ]],
122
-
123
- ['int ' , [[1 ],[2 ]]],
129
+
130
+ ['int ' , [[1 ], [2 ]]],
124
131
['int ' , [true , false ]],
125
- ['int ' , [function (){}, function (){}]],
132
+ ['int ' , [function () {
133
+ }, function () {
134
+ }]],
126
135
['int ' , [1.1 , 2.2 ]],
127
- ['int ' , [(object )['name ' => 'foo ' ], (object )['name ' => 'bar ' ]]],
136
+ ['int ' , [(object ) ['name ' => 'foo ' ], (object ) ['name ' => 'bar ' ]]],
128
137
['int ' , ['a ' , 'b ' ]],
129
-
130
- ['object ' , [[1 ],[2 ]]],
138
+
139
+ ['object ' , [[1 ], [2 ]]],
131
140
['object ' , [true , false ]],
132
141
//skip this because closure pass as object
133
142
//['object', [function(){}, function(){}]],
134
143
['object ' , [1.1 , 2.2 ]],
135
144
['object ' , [1 , 2 ]],
136
145
['object ' , ['a ' , 'b ' ]],
137
-
138
- ['string ' , [[1 ],[2 ]]],
146
+
147
+ ['string ' , [[1 ], [2 ]]],
139
148
['string ' , [true , false ]],
140
- ['string ' , [function (){}, function (){}]],
149
+ ['string ' , [function () {
150
+ }, function () {
151
+ }]],
141
152
['string ' , [1.1 , 2.2 ]],
142
153
['string ' , [1 , 2 ]],
143
- ['string ' , [(object )['name ' => 'foo ' ], (object )['name ' => 'bar ' ]]],
154
+ ['string ' , [(object ) ['name ' => 'foo ' ], (object ) ['name ' => 'bar ' ]]],
144
155
];
145
156
}
146
-
157
+
147
158
/**
148
159
* Test new instance passing array with invalid element to constructor.
149
160
*
@@ -154,25 +165,26 @@ public function testCreateInstanceWithWrongTypedArray($type, $array)
154
165
{
155
166
$ this ->assertInstanceOf (TypedArray::class, (new TypedArray ($ type , $ array )));
156
167
}
157
-
168
+
158
169
/**
159
170
* Provide values of right types.
160
- *
171
+ *
161
172
* @return array
162
173
*/
163
- function rightTypedValueProvider ()
174
+ public function rightTypedValueProvider ()
164
175
{
165
176
return [
166
- ['array ' ,[1 ]],
177
+ ['array ' , [1 ]],
167
178
['bool ' , true ],
168
- ['callable ' , function (){}],
179
+ ['callable ' , function () {
180
+ }],
169
181
['float ' , 1.1 ],
170
182
['int ' , 1 ],
171
- ['object ' ,(object )['name ' => 'foo ' ]],
183
+ ['object ' , (object ) ['name ' => 'foo ' ]],
172
184
['string ' , 'a ' ],
173
185
];
174
186
}
175
-
187
+
176
188
/**
177
189
* Test assign to array a right typed value.
178
190
*
@@ -185,67 +197,72 @@ public function testAssignrRightTypedValueToArray($type, $value)
185
197
186
198
$ this ->assertEquals (1 , $ array ->count ());
187
199
}
188
-
200
+
189
201
/**
190
202
* Provide values of wrong types.
191
- *
203
+ *
192
204
* @return array
193
205
*/
194
- function wrongTypedValueProvider ()
206
+ public function wrongTypedValueProvider ()
195
207
{
196
208
return [
197
209
['array ' , true ],
198
- ['array ' , function (){}],
210
+ ['array ' , function () {
211
+ }],
199
212
['array ' , 1.1 ],
200
213
['array ' , 1 ],
201
- ['array ' , (object )['name ' => 'foo ' ]],
214
+ ['array ' , (object ) ['name ' => 'foo ' ]],
202
215
['array ' , 'a ' ],
203
-
216
+
204
217
['bool ' , [1 ]],
205
- ['bool ' , function (){}],
218
+ ['bool ' , function () {
219
+ }],
206
220
['bool ' , 1.1 ],
207
221
['bool ' , 1 ],
208
- ['bool ' , (object )['name ' => 'foo ' ]],
222
+ ['bool ' , (object ) ['name ' => 'foo ' ]],
209
223
['bool ' , 'a ' ],
210
-
224
+
211
225
['callable ' , [1 ]],
212
226
['callable ' , true ],
213
227
['callable ' , 1.1 ],
214
228
['callable ' , 1 ],
215
- ['callable ' , (object )['name ' => 'foo ' ]],
216
- ['callable ' , 'a ' ],
217
-
229
+ ['callable ' , (object ) ['name ' => 'foo ' ]],
230
+ ['callable ' , 'a ' ],
231
+
218
232
['float ' , [1 ]],
219
233
['float ' , true ],
220
- ['float ' , function (){}],
234
+ ['float ' , function () {
235
+ }],
221
236
['float ' , 1 ],
222
- ['float ' , (object )['name ' => 'foo ' ]],
237
+ ['float ' , (object ) ['name ' => 'foo ' ]],
223
238
['float ' , 'a ' ],
224
-
239
+
225
240
['int ' , [1 ]],
226
241
['int ' , true ],
227
- ['int ' , function (){}],
242
+ ['int ' , function () {
243
+ }],
228
244
['int ' , 1.1 ],
229
- ['int ' , (object )['name ' => 'foo ' ]],
245
+ ['int ' , (object ) ['name ' => 'foo ' ]],
230
246
['int ' , 'a ' , 'b ' ],
231
-
247
+
232
248
['object ' , [1 ]],
233
249
['object ' , true ],
234
250
//skip this because closure pass as object
235
251
//['object',[function(){}, function(){}]],
236
252
['object ' , 1.1 ],
237
253
['object ' , 1 ],
238
254
['object ' , 'a ' ],
239
-
255
+
240
256
['string ' , [1 ]],
241
257
['string ' , true ],
242
- ['string ' , function (){}],
258
+ ['string ' , function () {
259
+ }],
243
260
['string ' , 1.1 ],
244
261
['string ' , 1 ],
245
- ['string ' , (object )['name ' => 'foo ' ]],
262
+ ['string ' , (object ) ['name ' => 'foo ' ]],
246
263
];
247
264
}
248
-
265
+
249
266
/**
250
267
* Test assign to array a wrong typed value.
251
268
*
0 commit comments