|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of PHPUnit. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Sebastian Bergmann <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace PHPUnit\Framework; |
|
12
|
|
|
|
|
13
|
|
|
use PHPUnit\Util\Xml; |
|
14
|
|
|
|
|
15
|
|
|
class AssertTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
private $filesDirectory; |
|
21
|
|
|
|
|
22
|
|
|
protected function setUp() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->filesDirectory = \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testFail() |
|
28
|
|
|
{ |
|
29
|
|
|
try { |
|
30
|
|
|
$this->fail(); |
|
31
|
|
|
} catch (AssertionFailedError $e) { |
|
32
|
|
|
return; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
throw new AssertionFailedError('Fail did not throw fail exception'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testAssertSplObjectStorageContainsObject() |
|
39
|
|
|
{ |
|
40
|
|
|
$a = new \stdClass; |
|
41
|
|
|
$b = new \stdClass; |
|
42
|
|
|
$c = new \SplObjectStorage; |
|
43
|
|
|
$c->attach($a); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertContains($a, $c); |
|
46
|
|
|
|
|
47
|
|
|
$this->expectException(AssertionFailedError::class); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertContains($b, $c); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testAssertArrayContainsObject() |
|
53
|
|
|
{ |
|
54
|
|
|
$a = new \stdClass; |
|
55
|
|
|
$b = new \stdClass; |
|
56
|
|
|
|
|
57
|
|
|
$this->assertContains($a, [$a]); |
|
58
|
|
|
|
|
59
|
|
|
$this->expectException(AssertionFailedError::class); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertContains($a, [$b]); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function testAssertArrayContainsString() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->assertContains('foo', ['foo']); |
|
67
|
|
|
|
|
68
|
|
|
$this->expectException(AssertionFailedError::class); |
|
69
|
|
|
|
|
70
|
|
|
$this->assertContains('foo', ['bar']); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function testAssertArrayContainsNonObject() |
|
74
|
|
|
{ |
|
75
|
|
|
$this->assertContains('foo', [true]); |
|
76
|
|
|
|
|
77
|
|
|
$this->expectException(AssertionFailedError::class); |
|
78
|
|
|
|
|
79
|
|
|
$this->assertContains('foo', [true], '', false, true, true); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function testAssertContainsOnlyInstancesOf() |
|
83
|
|
|
{ |
|
84
|
|
|
$test = [new \Book, new \Book]; |
|
85
|
|
|
|
|
86
|
|
|
$this->assertContainsOnlyInstancesOf(\Book::class, $test); |
|
87
|
|
|
$this->assertContainsOnlyInstancesOf(\stdClass::class, [new \stdClass()]); |
|
88
|
|
|
|
|
89
|
|
|
$test2 = [new \Author('Test')]; |
|
90
|
|
|
|
|
91
|
|
|
$this->expectException(AssertionFailedError::class); |
|
92
|
|
|
|
|
93
|
|
|
$this->assertContainsOnlyInstancesOf(\Book::class, $test2); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function testAssertArrayHasKeyThrowsExceptionForInvalidFirstArgument() |
|
97
|
|
|
{ |
|
98
|
|
|
$this->expectException(Exception::class); |
|
99
|
|
|
|
|
100
|
|
|
$this->assertArrayHasKey(null, []); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function testAssertArrayHasKeyThrowsExceptionForInvalidSecondArgument() |
|
104
|
|
|
{ |
|
105
|
|
|
$this->expectException(Exception::class); |
|
106
|
|
|
|
|
107
|
|
|
$this->assertArrayHasKey(0, null); |
|
|
|
|
|
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function testAssertArrayHasIntegerKey() |
|
111
|
|
|
{ |
|
112
|
|
|
$this->assertArrayHasKey(0, ['foo']); |
|
113
|
|
|
|
|
114
|
|
|
$this->expectException(AssertionFailedError::class); |
|
115
|
|
|
|
|
116
|
|
|
$this->assertArrayHasKey(1, ['foo']); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function testAssertArraySubset() |
|
120
|
|
|
{ |
|
121
|
|
|
$array = [ |
|
122
|
|
|
'a' => 'item a', |
|
123
|
|
|
'b' => 'item b', |
|
124
|
|
|
'c' => ['a2' => 'item a2', 'b2' => 'item b2'], |
|
125
|
|
|
'd' => ['a2' => ['a3' => 'item a3', 'b3' => 'item b3']] |
|
126
|
|
|
]; |
|
127
|
|
|
|
|
128
|
|
|
$this->assertArraySubset(['a' => 'item a', 'c' => ['a2' => 'item a2']], $array); |
|
129
|
|
|
$this->assertArraySubset(['a' => 'item a', 'd' => ['a2' => ['b3' => 'item b3']]], $array); |
|
130
|
|
|
|
|
131
|
|
|
$arrayAccessData = new \ArrayObject($array); |
|
132
|
|
|
|
|
133
|
|
|
$this->assertArraySubset(['a' => 'item a', 'c' => ['a2' => 'item a2']], $arrayAccessData); |
|
134
|
|
|
$this->assertArraySubset(['a' => 'item a', 'd' => ['a2' => ['b3' => 'item b3']]], $arrayAccessData); |
|
135
|
|
|
|
|
136
|
|
|
try { |
|
137
|
|
|
$this->assertArraySubset(['a' => 'bad value'], $array); |
|
138
|
|
|
} catch (AssertionFailedError $e) { |
|
|
|
|
|
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
try { |
|
142
|
|
|
$this->assertArraySubset(['d' => ['a2' => ['bad index' => 'item b3']]], $array); |
|
143
|
|
|
} catch (AssertionFailedError $e) { |
|
144
|
|
|
return; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
$this->fail(); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
public function testAssertArraySubsetWithDeepNestedArrays() |
|
151
|
|
|
{ |
|
152
|
|
|
$array = [ |
|
153
|
|
|
'path' => [ |
|
154
|
|
|
'to' => [ |
|
155
|
|
|
'the' => [ |
|
156
|
|
|
'cake' => 'is a lie' |
|
157
|
|
|
] |
|
158
|
|
|
] |
|
159
|
|
|
] |
|
160
|
|
|
]; |
|
161
|
|
|
|
|
162
|
|
|
$this->assertArraySubset(['path' => []], $array); |
|
163
|
|
|
$this->assertArraySubset(['path' => ['to' => []]], $array); |
|
164
|
|
|
$this->assertArraySubset(['path' => ['to' => ['the' => []]]], $array); |
|
165
|
|
|
$this->assertArraySubset(['path' => ['to' => ['the' => ['cake' => 'is a lie']]]], $array); |
|
166
|
|
|
|
|
167
|
|
|
$this->expectException(AssertionFailedError::class); |
|
168
|
|
|
|
|
169
|
|
|
$this->assertArraySubset(['path' => ['to' => ['the' => ['cake' => 'is not a lie']]]], $array); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function testAssertArraySubsetWithNoStrictCheckAndObjects() |
|
173
|
|
|
{ |
|
174
|
|
|
$obj = new \stdClass; |
|
175
|
|
|
$reference = &$obj; |
|
176
|
|
|
$array = ['a' => $obj]; |
|
177
|
|
|
|
|
178
|
|
|
$this->assertArraySubset(['a' => $reference], $array); |
|
179
|
|
|
$this->assertArraySubset(['a' => new \stdClass], $array); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
public function testAssertArraySubsetWithStrictCheckAndObjects() |
|
183
|
|
|
{ |
|
184
|
|
|
$obj = new \stdClass; |
|
185
|
|
|
$reference = &$obj; |
|
186
|
|
|
$array = ['a' => $obj]; |
|
187
|
|
|
|
|
188
|
|
|
$this->assertArraySubset(['a' => $reference], $array, true); |
|
189
|
|
|
|
|
190
|
|
|
$this->expectException(AssertionFailedError::class); |
|
191
|
|
|
|
|
192
|
|
|
$this->assertArraySubset(['a' => new \stdClass], $array, true); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* @dataProvider assertArraySubsetInvalidArgumentProvider |
|
197
|
|
|
*/ |
|
198
|
|
|
public function testAssertArraySubsetRaisesExceptionForInvalidArguments($partial, $subject) |
|
199
|
|
|
{ |
|
200
|
|
|
$this->expectException(Exception::class); |
|
201
|
|
|
|
|
202
|
|
|
$this->assertArraySubset($partial, $subject); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @return array |
|
207
|
|
|
*/ |
|
208
|
|
|
public function assertArraySubsetInvalidArgumentProvider() |
|
209
|
|
|
{ |
|
210
|
|
|
return [ |
|
211
|
|
|
[false, []], |
|
212
|
|
|
[[], false], |
|
213
|
|
|
]; |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
public function testAssertArrayNotHasKeyThrowsExceptionForInvalidFirstArgument() |
|
217
|
|
|
{ |
|
218
|
|
|
$this->expectException(Exception::class); |
|
219
|
|
|
|
|
220
|
|
|
$this->assertArrayNotHasKey(null, []); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
public function testAssertArrayNotHasKeyThrowsExceptionForInvalidSecondArgument() |
|
224
|
|
|
{ |
|
225
|
|
|
$this->expectException(Exception::class); |
|
226
|
|
|
|
|
227
|
|
|
$this->assertArrayNotHasKey(0, null); |
|
|
|
|
|
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
public function testAssertArrayNotHasIntegerKey() |
|
231
|
|
|
{ |
|
232
|
|
|
$this->assertArrayNotHasKey(1, ['foo']); |
|
233
|
|
|
|
|
234
|
|
|
$this->expectException(AssertionFailedError::class); |
|
235
|
|
|
|
|
236
|
|
|
$this->assertArrayNotHasKey(0, ['foo']); |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
public function testAssertArrayHasStringKey() |
|
240
|
|
|
{ |
|
241
|
|
|
$this->assertArrayHasKey('foo', ['foo' => 'bar']); |
|
242
|
|
|
|
|
243
|
|
|
$this->expectException(AssertionFailedError::class); |
|
244
|
|
|
|
|
245
|
|
|
$this->assertArrayHasKey('bar', ['foo' => 'bar']); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
public function testAssertArrayNotHasStringKey() |
|
249
|
|
|
{ |
|
250
|
|
|
$this->assertArrayNotHasKey('bar', ['foo' => 'bar']); |
|
251
|
|
|
|
|
252
|
|
|
$this->expectException(AssertionFailedError::class); |
|
253
|
|
|
|
|
254
|
|
|
$this->assertArrayNotHasKey('foo', ['foo' => 'bar']); |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
public function testAssertArrayHasKeyAcceptsArrayObjectValue() |
|
258
|
|
|
{ |
|
259
|
|
|
$array = new \ArrayObject; |
|
260
|
|
|
$array['foo'] = 'bar'; |
|
261
|
|
|
|
|
262
|
|
|
$this->assertArrayHasKey('foo', $array); |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
public function testAssertArrayHasKeyProperlyFailsWithArrayObjectValue() |
|
266
|
|
|
{ |
|
267
|
|
|
$array = new \ArrayObject; |
|
268
|
|
|
$array['bar'] = 'bar'; |
|
269
|
|
|
|
|
270
|
|
|
$this->expectException(AssertionFailedError::class); |
|
271
|
|
|
|
|
272
|
|
|
$this->assertArrayHasKey('foo', $array); |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
public function testAssertArrayHasKeyAcceptsArrayAccessValue() |
|
276
|
|
|
{ |
|
277
|
|
|
$array = new \SampleArrayAccess; |
|
278
|
|
|
$array['foo'] = 'bar'; |
|
279
|
|
|
|
|
280
|
|
|
$this->assertArrayHasKey('foo', $array); |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
public function testAssertArrayHasKeyProperlyFailsWithArrayAccessValue() |
|
284
|
|
|
{ |
|
285
|
|
|
$array = new \SampleArrayAccess; |
|
286
|
|
|
$array['bar'] = 'bar'; |
|
287
|
|
|
|
|
288
|
|
|
$this->expectException(AssertionFailedError::class); |
|
289
|
|
|
|
|
290
|
|
|
$this->assertArrayHasKey('foo', $array); |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
public function testAssertArrayNotHasKeyAcceptsArrayAccessValue() |
|
294
|
|
|
{ |
|
295
|
|
|
$array = new \ArrayObject; |
|
296
|
|
|
$array['foo'] = 'bar'; |
|
297
|
|
|
|
|
298
|
|
|
$this->assertArrayNotHasKey('bar', $array); |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
public function testAssertArrayNotHasKeyPropertlyFailsWithArrayAccessValue() |
|
302
|
|
|
{ |
|
303
|
|
|
$array = new \ArrayObject; |
|
304
|
|
|
$array['bar'] = 'bar'; |
|
305
|
|
|
|
|
306
|
|
|
$this->expectException(AssertionFailedError::class); |
|
307
|
|
|
|
|
308
|
|
|
$this->assertArrayNotHasKey('bar', $array); |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
public function testAssertContainsThrowsException() |
|
312
|
|
|
{ |
|
313
|
|
|
$this->expectException(Exception::class); |
|
314
|
|
|
|
|
315
|
|
|
$this->assertContains(null, null); |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
public function testAssertIteratorContainsObject() |
|
319
|
|
|
{ |
|
320
|
|
|
$foo = new \stdClass; |
|
321
|
|
|
|
|
322
|
|
|
$this->assertContains($foo, new \TestIterator([$foo])); |
|
323
|
|
|
|
|
324
|
|
|
$this->expectException(AssertionFailedError::class); |
|
325
|
|
|
|
|
326
|
|
|
$this->assertContains($foo, new \TestIterator([new \stdClass])); |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
public function testAssertIteratorContainsString() |
|
330
|
|
|
{ |
|
331
|
|
|
$this->assertContains('foo', new \TestIterator(['foo'])); |
|
332
|
|
|
|
|
333
|
|
|
$this->expectException(AssertionFailedError::class); |
|
334
|
|
|
|
|
335
|
|
|
$this->assertContains('foo', new \TestIterator(['bar'])); |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
public function testAssertStringContainsString() |
|
339
|
|
|
{ |
|
340
|
|
|
$this->assertContains('foo', 'foobar'); |
|
341
|
|
|
|
|
342
|
|
|
$this->expectException(AssertionFailedError::class); |
|
343
|
|
|
|
|
344
|
|
|
$this->assertContains('foo', 'bar'); |
|
345
|
|
|
} |
|
346
|
|
|
|
|
347
|
|
|
public function testAssertStringContainsStringForUtf8() |
|
348
|
|
|
{ |
|
349
|
|
|
$this->assertContains('oryginał', 'oryginał'); |
|
350
|
|
|
|
|
351
|
|
|
$this->expectException(AssertionFailedError::class); |
|
352
|
|
|
|
|
353
|
|
|
$this->assertContains('ORYGINAŁ', 'oryginał'); |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
public function testAssertStringContainsStringForUtf8WhenIgnoreCase() |
|
357
|
|
|
{ |
|
358
|
|
|
$this->assertContains('oryginał', 'oryginał', '', true); |
|
359
|
|
|
$this->assertContains('ORYGINAŁ', 'oryginał', '', true); |
|
360
|
|
|
|
|
361
|
|
|
$this->expectException(AssertionFailedError::class); |
|
362
|
|
|
|
|
363
|
|
|
$this->assertContains('foo', 'oryginał', '', true); |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
public function testAssertNotContainsThrowsException() |
|
367
|
|
|
{ |
|
368
|
|
|
$this->expectException(Exception::class); |
|
369
|
|
|
|
|
370
|
|
|
$this->assertNotContains(null, null); |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
public function testAssertSplObjectStorageNotContainsObject() |
|
374
|
|
|
{ |
|
375
|
|
|
$a = new \stdClass; |
|
376
|
|
|
$b = new \stdClass; |
|
377
|
|
|
$c = new \SplObjectStorage; |
|
378
|
|
|
$c->attach($a); |
|
379
|
|
|
|
|
380
|
|
|
$this->assertNotContains($b, $c); |
|
381
|
|
|
|
|
382
|
|
|
$this->expectException(AssertionFailedError::class); |
|
383
|
|
|
|
|
384
|
|
|
$this->assertNotContains($a, $c); |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
public function testAssertArrayNotContainsObject() |
|
388
|
|
|
{ |
|
389
|
|
|
$a = new \stdClass; |
|
390
|
|
|
$b = new \stdClass; |
|
391
|
|
|
|
|
392
|
|
|
$this->assertNotContains($a, [$b]); |
|
393
|
|
|
|
|
394
|
|
|
$this->expectException(AssertionFailedError::class); |
|
395
|
|
|
|
|
396
|
|
|
$this->assertNotContains($a, [$a]); |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
public function testAssertArrayNotContainsString() |
|
400
|
|
|
{ |
|
401
|
|
|
$this->assertNotContains('foo', ['bar']); |
|
402
|
|
|
|
|
403
|
|
|
$this->expectException(AssertionFailedError::class); |
|
404
|
|
|
|
|
405
|
|
|
$this->assertNotContains('foo', ['foo']); |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
public function testAssertArrayNotContainsNonObject() |
|
409
|
|
|
{ |
|
410
|
|
|
$this->assertNotContains('foo', [true], '', false, true, true); |
|
411
|
|
|
|
|
412
|
|
|
$this->expectException(AssertionFailedError::class); |
|
413
|
|
|
|
|
414
|
|
|
$this->assertNotContains('foo', [true]); |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
public function testAssertStringNotContainsString() |
|
418
|
|
|
{ |
|
419
|
|
|
$this->assertNotContains('foo', 'bar'); |
|
420
|
|
|
|
|
421
|
|
|
$this->expectException(AssertionFailedError::class); |
|
422
|
|
|
|
|
423
|
|
|
$this->assertNotContains('foo', 'foo'); |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
public function testAssertStringNotContainsStringForUtf8() |
|
427
|
|
|
{ |
|
428
|
|
|
$this->assertNotContains('ORYGINAŁ', 'oryginał'); |
|
429
|
|
|
|
|
430
|
|
|
$this->expectException(AssertionFailedError::class); |
|
431
|
|
|
|
|
432
|
|
|
$this->assertNotContains('oryginał', 'oryginał'); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
public function testAssertStringNotContainsStringForUtf8WhenIgnoreCase() |
|
436
|
|
|
{ |
|
437
|
|
|
$this->expectException(AssertionFailedError::class); |
|
438
|
|
|
|
|
439
|
|
|
$this->assertNotContains('ORYGINAŁ', 'oryginał', '', true); |
|
440
|
|
|
} |
|
441
|
|
|
|
|
442
|
|
|
public function testAssertContainsOnlyThrowsException() |
|
443
|
|
|
{ |
|
444
|
|
|
$this->expectException(Exception::class); |
|
445
|
|
|
|
|
446
|
|
|
$this->assertContainsOnly(null, null); |
|
447
|
|
|
} |
|
448
|
|
|
|
|
449
|
|
|
public function testAssertNotContainsOnlyThrowsException() |
|
450
|
|
|
{ |
|
451
|
|
|
$this->expectException(Exception::class); |
|
452
|
|
|
|
|
453
|
|
|
$this->assertNotContainsOnly(null, null); |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
public function testAssertContainsOnlyInstancesOfThrowsException() |
|
457
|
|
|
{ |
|
458
|
|
|
$this->expectException(Exception::class); |
|
459
|
|
|
|
|
460
|
|
|
$this->assertContainsOnlyInstancesOf(null, null); |
|
|
|
|
|
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
public function testAssertArrayContainsOnlyIntegers() |
|
464
|
|
|
{ |
|
465
|
|
|
$this->assertContainsOnly('integer', [1, 2, 3]); |
|
466
|
|
|
|
|
467
|
|
|
$this->expectException(AssertionFailedError::class); |
|
468
|
|
|
|
|
469
|
|
|
$this->assertContainsOnly('integer', ['1', 2, 3]); |
|
470
|
|
|
} |
|
471
|
|
|
|
|
472
|
|
|
public function testAssertArrayNotContainsOnlyIntegers() |
|
473
|
|
|
{ |
|
474
|
|
|
$this->assertNotContainsOnly('integer', ['1', 2, 3]); |
|
475
|
|
|
|
|
476
|
|
|
$this->expectException(AssertionFailedError::class); |
|
477
|
|
|
|
|
478
|
|
|
$this->assertNotContainsOnly('integer', [1, 2, 3]); |
|
479
|
|
|
} |
|
480
|
|
|
|
|
481
|
|
|
public function testAssertArrayContainsOnlyStdClass() |
|
482
|
|
|
{ |
|
483
|
|
|
$this->assertContainsOnly('StdClass', [new \stdClass]); |
|
484
|
|
|
|
|
485
|
|
|
$this->expectException(AssertionFailedError::class); |
|
486
|
|
|
|
|
487
|
|
|
$this->assertContainsOnly('StdClass', ['StdClass']); |
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
|
public function testAssertArrayNotContainsOnlyStdClass() |
|
491
|
|
|
{ |
|
492
|
|
|
$this->assertNotContainsOnly('StdClass', ['StdClass']); |
|
493
|
|
|
|
|
494
|
|
|
$this->expectException(AssertionFailedError::class); |
|
495
|
|
|
|
|
496
|
|
|
$this->assertNotContainsOnly('StdClass', [new \stdClass]); |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
protected function sameValues() |
|
500
|
|
|
{ |
|
501
|
|
|
$object = new \SampleClass(4, 8, 15); |
|
502
|
|
|
// cannot use $filesDirectory, because neither setUp() nor |
|
503
|
|
|
// setUpBeforeClass() are executed before the data providers |
|
504
|
|
|
$file = \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'foo.xml'; |
|
505
|
|
|
$resource = \fopen($file, 'r'); |
|
506
|
|
|
|
|
507
|
|
|
return [ |
|
508
|
|
|
// null |
|
509
|
|
|
[null, null], |
|
510
|
|
|
// strings |
|
511
|
|
|
['a', 'a'], |
|
512
|
|
|
// integers |
|
513
|
|
|
[0, 0], |
|
514
|
|
|
// floats |
|
515
|
|
|
[2.3, 2.3], |
|
516
|
|
|
[1 / 3, 1 - 2 / 3], |
|
517
|
|
|
[\log(0), \log(0)], |
|
518
|
|
|
// arrays |
|
519
|
|
|
[[], []], |
|
520
|
|
|
[[0 => 1], [0 => 1]], |
|
521
|
|
|
[[0 => null], [0 => null]], |
|
522
|
|
|
[['a', 'b' => [1, 2]], ['a', 'b' => [1, 2]]], |
|
523
|
|
|
// objects |
|
524
|
|
|
[$object, $object], |
|
525
|
|
|
// resources |
|
526
|
|
|
[$resource, $resource], |
|
527
|
|
|
]; |
|
528
|
|
|
} |
|
529
|
|
|
|
|
530
|
|
|
protected function notEqualValues() |
|
531
|
|
|
{ |
|
532
|
|
|
// cyclic dependencies |
|
533
|
|
|
$book1 = new \Book; |
|
534
|
|
|
$book1->author = new \Author('Terry Pratchett'); |
|
535
|
|
|
$book1->author->books[] = $book1; |
|
536
|
|
|
$book2 = new \Book; |
|
537
|
|
|
$book2->author = new \Author('Terry Pratch'); |
|
538
|
|
|
$book2->author->books[] = $book2; |
|
539
|
|
|
|
|
540
|
|
|
$book3 = new \Book; |
|
541
|
|
|
$book3->author = 'Terry Pratchett'; |
|
542
|
|
|
$book4 = new \stdClass; |
|
543
|
|
|
$book4->author = 'Terry Pratchett'; |
|
544
|
|
|
|
|
545
|
|
|
$object1 = new \SampleClass(4, 8, 15); |
|
546
|
|
|
$object2 = new \SampleClass(16, 23, 42); |
|
547
|
|
|
$object3 = new \SampleClass(4, 8, 15); |
|
548
|
|
|
$storage1 = new \SplObjectStorage; |
|
549
|
|
|
$storage1->attach($object1); |
|
550
|
|
|
$storage2 = new \SplObjectStorage; |
|
551
|
|
|
$storage2->attach($object3); // same content, different object |
|
552
|
|
|
|
|
553
|
|
|
// cannot use $filesDirectory, because neither setUp() nor |
|
554
|
|
|
// setUpBeforeClass() are executed before the data providers |
|
555
|
|
|
$file = \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'foo.xml'; |
|
556
|
|
|
|
|
557
|
|
|
return [ |
|
558
|
|
|
// strings |
|
559
|
|
|
['a', 'b'], |
|
560
|
|
|
['a', 'A'], |
|
561
|
|
|
// https://github.com/sebastianbergmann/phpunit/issues/1023 |
|
562
|
|
|
['9E6666666','9E7777777'], |
|
563
|
|
|
// integers |
|
564
|
|
|
[1, 2], |
|
565
|
|
|
[2, 1], |
|
566
|
|
|
// floats |
|
567
|
|
|
[2.3, 4.2], |
|
568
|
|
|
[2.3, 4.2, 0.5], |
|
569
|
|
|
[[2.3], [4.2], 0.5], |
|
570
|
|
|
[[[2.3]], [[4.2]], 0.5], |
|
571
|
|
|
[new \Struct(2.3), new \Struct(4.2), 0.5], |
|
572
|
|
|
[[new \Struct(2.3)], [new \Struct(4.2)], 0.5], |
|
573
|
|
|
// NAN |
|
574
|
|
|
[NAN, NAN], |
|
575
|
|
|
// arrays |
|
576
|
|
|
[[], [0 => 1]], |
|
577
|
|
|
[[0 => 1], []], |
|
578
|
|
|
[[0 => null], []], |
|
579
|
|
|
[[0 => 1, 1 => 2], [0 => 1, 1 => 3]], |
|
580
|
|
|
[['a', 'b' => [1, 2]], ['a', 'b' => [2, 1]]], |
|
581
|
|
|
// objects |
|
582
|
|
|
[new \SampleClass(4, 8, 15), new \SampleClass(16, 23, 42)], |
|
583
|
|
|
[$object1, $object2], |
|
584
|
|
|
[$book1, $book2], |
|
585
|
|
|
[$book3, $book4], // same content, different class |
|
586
|
|
|
// resources |
|
587
|
|
|
[\fopen($file, 'r'), \fopen($file, 'r')], |
|
588
|
|
|
// SplObjectStorage |
|
589
|
|
|
[$storage1, $storage2], |
|
590
|
|
|
// DOMDocument |
|
591
|
|
|
[ |
|
592
|
|
|
Xml::load('<root></root>'), |
|
593
|
|
|
Xml::load('<bar/>'), |
|
594
|
|
|
], |
|
595
|
|
|
[ |
|
596
|
|
|
Xml::load('<foo attr1="bar"/>'), |
|
597
|
|
|
Xml::load('<foo attr1="foobar"/>'), |
|
598
|
|
|
], |
|
599
|
|
|
[ |
|
600
|
|
|
Xml::load('<foo> bar </foo>'), |
|
601
|
|
|
Xml::load('<foo />'), |
|
602
|
|
|
], |
|
603
|
|
|
[ |
|
604
|
|
|
Xml::load('<foo xmlns="urn:myns:bar"/>'), |
|
605
|
|
|
Xml::load('<foo xmlns="urn:notmyns:bar"/>'), |
|
606
|
|
|
], |
|
607
|
|
|
[ |
|
608
|
|
|
Xml::load('<foo> bar </foo>'), |
|
609
|
|
|
Xml::load('<foo> bir </foo>'), |
|
610
|
|
|
], |
|
611
|
|
|
[ |
|
612
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
613
|
|
|
new \DateTime('2013-03-29 03:13:35', new \DateTimeZone('America/New_York')), |
|
614
|
|
|
], |
|
615
|
|
|
[ |
|
616
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
617
|
|
|
new \DateTime('2013-03-29 03:13:35', new \DateTimeZone('America/New_York')), |
|
618
|
|
|
3500 |
|
619
|
|
|
], |
|
620
|
|
|
[ |
|
621
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
622
|
|
|
new \DateTime('2013-03-29 05:13:35', new \DateTimeZone('America/New_York')), |
|
623
|
|
|
3500 |
|
624
|
|
|
], |
|
625
|
|
|
[ |
|
626
|
|
|
new \DateTime('2013-03-29', new \DateTimeZone('America/New_York')), |
|
627
|
|
|
new \DateTime('2013-03-30', new \DateTimeZone('America/New_York')), |
|
628
|
|
|
], |
|
629
|
|
|
[ |
|
630
|
|
|
new \DateTime('2013-03-29', new \DateTimeZone('America/New_York')), |
|
631
|
|
|
new \DateTime('2013-03-30', new \DateTimeZone('America/New_York')), |
|
632
|
|
|
43200 |
|
633
|
|
|
], |
|
634
|
|
|
[ |
|
635
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
636
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/Chicago')), |
|
637
|
|
|
], |
|
638
|
|
|
[ |
|
639
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
640
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/Chicago')), |
|
641
|
|
|
3500 |
|
642
|
|
|
], |
|
643
|
|
|
[ |
|
644
|
|
|
new \DateTime('2013-03-30', new \DateTimeZone('America/New_York')), |
|
645
|
|
|
new \DateTime('2013-03-30', new \DateTimeZone('America/Chicago')), |
|
646
|
|
|
], |
|
647
|
|
|
[ |
|
648
|
|
|
new \DateTime('2013-03-29T05:13:35-0600'), |
|
649
|
|
|
new \DateTime('2013-03-29T04:13:35-0600'), |
|
650
|
|
|
], |
|
651
|
|
|
[ |
|
652
|
|
|
new \DateTime('2013-03-29T05:13:35-0600'), |
|
653
|
|
|
new \DateTime('2013-03-29T05:13:35-0500'), |
|
654
|
|
|
], |
|
655
|
|
|
// Exception |
|
656
|
|
|
//array(new Exception('Exception 1'), new Exception('Exception 2')), |
|
657
|
|
|
// different types |
|
658
|
|
|
[new \SampleClass(4, 8, 15), false], |
|
659
|
|
|
[false, new \SampleClass(4, 8, 15)], |
|
660
|
|
|
[[0 => 1, 1 => 2], false], |
|
661
|
|
|
[false, [0 => 1, 1 => 2]], |
|
662
|
|
|
[[], new \stdClass], |
|
663
|
|
|
[new \stdClass, []], |
|
664
|
|
|
// PHP: 0 == 'Foobar' => true! |
|
665
|
|
|
// We want these values to differ |
|
666
|
|
|
[0, 'Foobar'], |
|
667
|
|
|
['Foobar', 0], |
|
668
|
|
|
[3, \acos(8)], |
|
669
|
|
|
[\acos(8), 3] |
|
670
|
|
|
]; |
|
671
|
|
|
} |
|
672
|
|
|
|
|
673
|
|
|
protected function equalValues() |
|
674
|
|
|
{ |
|
675
|
|
|
// cyclic dependencies |
|
676
|
|
|
$book1 = new \Book; |
|
677
|
|
|
$book1->author = new \Author('Terry Pratchett'); |
|
678
|
|
|
$book1->author->books[] = $book1; |
|
679
|
|
|
$book2 = new \Book; |
|
680
|
|
|
$book2->author = new \Author('Terry Pratchett'); |
|
681
|
|
|
$book2->author->books[] = $book2; |
|
682
|
|
|
|
|
683
|
|
|
$object1 = new \SampleClass(4, 8, 15); |
|
684
|
|
|
$object2 = new \SampleClass(4, 8, 15); |
|
685
|
|
|
$storage1 = new \SplObjectStorage; |
|
686
|
|
|
$storage1->attach($object1); |
|
687
|
|
|
$storage2 = new \SplObjectStorage; |
|
688
|
|
|
$storage2->attach($object1); |
|
689
|
|
|
|
|
690
|
|
|
return [ |
|
691
|
|
|
// strings |
|
692
|
|
|
['a', 'A', 0, false, true], // ignore case |
|
693
|
|
|
// arrays |
|
694
|
|
|
[['a' => 1, 'b' => 2], ['b' => 2, 'a' => 1]], |
|
695
|
|
|
[[1], ['1']], |
|
696
|
|
|
[[3, 2, 1], [2, 3, 1], 0, true], // canonicalized comparison |
|
697
|
|
|
// floats |
|
698
|
|
|
[2.3, 2.5, 0.5], |
|
699
|
|
|
[[2.3], [2.5], 0.5], |
|
700
|
|
|
[[[2.3]], [[2.5]], 0.5], |
|
701
|
|
|
[new \Struct(2.3), new \Struct(2.5), 0.5], |
|
702
|
|
|
[[new \Struct(2.3)], [new \Struct(2.5)], 0.5], |
|
703
|
|
|
// numeric with delta |
|
704
|
|
|
[1, 2, 1], |
|
705
|
|
|
// objects |
|
706
|
|
|
[$object1, $object2], |
|
707
|
|
|
[$book1, $book2], |
|
708
|
|
|
// SplObjectStorage |
|
709
|
|
|
[$storage1, $storage2], |
|
710
|
|
|
// DOMDocument |
|
711
|
|
|
[ |
|
712
|
|
|
Xml::load('<root></root>'), |
|
713
|
|
|
Xml::load('<root/>'), |
|
714
|
|
|
], |
|
715
|
|
|
[ |
|
716
|
|
|
Xml::load('<root attr="bar"></root>'), |
|
717
|
|
|
Xml::load('<root attr="bar"/>'), |
|
718
|
|
|
], |
|
719
|
|
|
[ |
|
720
|
|
|
Xml::load('<root><foo attr="bar"></foo></root>'), |
|
721
|
|
|
Xml::load('<root><foo attr="bar"/></root>'), |
|
722
|
|
|
], |
|
723
|
|
|
[ |
|
724
|
|
|
Xml::load("<root>\n <child/>\n</root>"), |
|
725
|
|
|
Xml::load('<root><child/></root>'), |
|
726
|
|
|
], |
|
727
|
|
|
[ |
|
728
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
729
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
730
|
|
|
], |
|
731
|
|
|
[ |
|
732
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
733
|
|
|
new \DateTime('2013-03-29 04:13:25', new \DateTimeZone('America/New_York')), |
|
734
|
|
|
10 |
|
735
|
|
|
], |
|
736
|
|
|
[ |
|
737
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
738
|
|
|
new \DateTime('2013-03-29 04:14:40', new \DateTimeZone('America/New_York')), |
|
739
|
|
|
65 |
|
740
|
|
|
], |
|
741
|
|
|
[ |
|
742
|
|
|
new \DateTime('2013-03-29', new \DateTimeZone('America/New_York')), |
|
743
|
|
|
new \DateTime('2013-03-29', new \DateTimeZone('America/New_York')), |
|
744
|
|
|
], |
|
745
|
|
|
[ |
|
746
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
747
|
|
|
new \DateTime('2013-03-29 03:13:35', new \DateTimeZone('America/Chicago')), |
|
748
|
|
|
], |
|
749
|
|
|
[ |
|
750
|
|
|
new \DateTime('2013-03-29 04:13:35', new \DateTimeZone('America/New_York')), |
|
751
|
|
|
new \DateTime('2013-03-29 03:13:49', new \DateTimeZone('America/Chicago')), |
|
752
|
|
|
15 |
|
753
|
|
|
], |
|
754
|
|
|
[ |
|
755
|
|
|
new \DateTime('2013-03-30', new \DateTimeZone('America/New_York')), |
|
756
|
|
|
new \DateTime('2013-03-29 23:00:00', new \DateTimeZone('America/Chicago')), |
|
757
|
|
|
], |
|
758
|
|
|
[ |
|
759
|
|
|
new \DateTime('2013-03-30', new \DateTimeZone('America/New_York')), |
|
760
|
|
|
new \DateTime('2013-03-29 23:01:30', new \DateTimeZone('America/Chicago')), |
|
761
|
|
|
100 |
|
762
|
|
|
], |
|
763
|
|
|
[ |
|
764
|
|
|
new \DateTime('@1364616000'), |
|
765
|
|
|
new \DateTime('2013-03-29 23:00:00', new \DateTimeZone('America/Chicago')), |
|
766
|
|
|
], |
|
767
|
|
|
[ |
|
768
|
|
|
new \DateTime('2013-03-29T05:13:35-0500'), |
|
769
|
|
|
new \DateTime('2013-03-29T04:13:35-0600'), |
|
770
|
|
|
], |
|
771
|
|
|
// Exception |
|
772
|
|
|
//array(new Exception('Exception 1'), new Exception('Exception 1')), |
|
773
|
|
|
// mixed types |
|
774
|
|
|
[0, '0'], |
|
775
|
|
|
['0', 0], |
|
776
|
|
|
[2.3, '2.3'], |
|
777
|
|
|
['2.3', 2.3], |
|
778
|
|
|
[(string) (1 / 3), 1 - 2 / 3], |
|
779
|
|
|
[1 / 3, (string) (1 - 2 / 3)], |
|
780
|
|
|
['string representation', new \ClassWithToString], |
|
781
|
|
|
[new \ClassWithToString, 'string representation'], |
|
782
|
|
|
]; |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
public function equalProvider() |
|
786
|
|
|
{ |
|
787
|
|
|
// same |= equal |
|
788
|
|
|
return \array_merge($this->equalValues(), $this->sameValues()); |
|
789
|
|
|
} |
|
790
|
|
|
|
|
791
|
|
|
public function notEqualProvider() |
|
792
|
|
|
{ |
|
793
|
|
|
return $this->notEqualValues(); |
|
794
|
|
|
} |
|
795
|
|
|
|
|
796
|
|
|
public function sameProvider() |
|
797
|
|
|
{ |
|
798
|
|
|
return $this->sameValues(); |
|
799
|
|
|
} |
|
800
|
|
|
|
|
801
|
|
|
public function notSameProvider() |
|
802
|
|
|
{ |
|
803
|
|
|
// not equal |= not same |
|
804
|
|
|
// equal, ¬same |= not same |
|
805
|
|
|
return \array_merge($this->notEqualValues(), $this->equalValues()); |
|
806
|
|
|
} |
|
807
|
|
|
|
|
808
|
|
|
/** |
|
809
|
|
|
* @dataProvider equalProvider |
|
810
|
|
|
*/ |
|
811
|
|
|
public function testAssertEqualsSucceeds($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
|
812
|
|
|
{ |
|
813
|
|
|
$this->assertEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
|
814
|
|
|
} |
|
815
|
|
|
|
|
816
|
|
|
/** |
|
817
|
|
|
* @dataProvider notEqualProvider |
|
818
|
|
|
*/ |
|
819
|
|
|
public function testAssertEqualsFails($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
|
820
|
|
|
{ |
|
821
|
|
|
$this->expectException(AssertionFailedError::class); |
|
822
|
|
|
|
|
823
|
|
|
$this->assertEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
|
824
|
|
|
} |
|
825
|
|
|
|
|
826
|
|
|
/** |
|
827
|
|
|
* @dataProvider notEqualProvider |
|
828
|
|
|
*/ |
|
829
|
|
|
public function testAssertNotEqualsSucceeds($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
|
830
|
|
|
{ |
|
831
|
|
|
$this->assertNotEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
|
832
|
|
|
} |
|
833
|
|
|
|
|
834
|
|
|
/** |
|
835
|
|
|
* @dataProvider equalProvider |
|
836
|
|
|
*/ |
|
837
|
|
|
public function testAssertNotEqualsFails($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
|
838
|
|
|
{ |
|
839
|
|
|
$this->expectException(AssertionFailedError::class); |
|
840
|
|
|
|
|
841
|
|
|
$this->assertNotEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
|
842
|
|
|
} |
|
843
|
|
|
|
|
844
|
|
|
/** |
|
845
|
|
|
* @dataProvider sameProvider |
|
846
|
|
|
*/ |
|
847
|
|
|
public function testAssertSameSucceeds($a, $b) |
|
848
|
|
|
{ |
|
849
|
|
|
$this->assertSame($a, $b); |
|
850
|
|
|
} |
|
851
|
|
|
|
|
852
|
|
|
/** |
|
853
|
|
|
* @dataProvider notSameProvider |
|
854
|
|
|
*/ |
|
855
|
|
|
public function testAssertSameFails($a, $b) |
|
856
|
|
|
{ |
|
857
|
|
|
$this->expectException(AssertionFailedError::class); |
|
858
|
|
|
|
|
859
|
|
|
$this->assertSame($a, $b); |
|
860
|
|
|
} |
|
861
|
|
|
|
|
862
|
|
|
/** |
|
863
|
|
|
* @dataProvider notSameProvider |
|
864
|
|
|
*/ |
|
865
|
|
|
public function testAssertNotSameSucceeds($a, $b) |
|
866
|
|
|
{ |
|
867
|
|
|
$this->assertNotSame($a, $b); |
|
868
|
|
|
} |
|
869
|
|
|
|
|
870
|
|
|
/** |
|
871
|
|
|
* @dataProvider sameProvider |
|
872
|
|
|
*/ |
|
873
|
|
|
public function testAssertNotSameFails($a, $b) |
|
874
|
|
|
{ |
|
875
|
|
|
$this->expectException(AssertionFailedError::class); |
|
876
|
|
|
|
|
877
|
|
|
$this->assertNotSame($a, $b); |
|
878
|
|
|
} |
|
879
|
|
|
|
|
880
|
|
|
public function testAssertXmlFileEqualsXmlFile() |
|
881
|
|
|
{ |
|
882
|
|
|
$this->assertXmlFileEqualsXmlFile( |
|
883
|
|
|
$this->filesDirectory . 'foo.xml', |
|
884
|
|
|
$this->filesDirectory . 'foo.xml' |
|
885
|
|
|
); |
|
886
|
|
|
|
|
887
|
|
|
$this->expectException(AssertionFailedError::class); |
|
888
|
|
|
|
|
889
|
|
|
$this->assertXmlFileEqualsXmlFile( |
|
890
|
|
|
$this->filesDirectory . 'foo.xml', |
|
891
|
|
|
$this->filesDirectory . 'bar.xml' |
|
892
|
|
|
); |
|
893
|
|
|
} |
|
894
|
|
|
|
|
895
|
|
|
public function testAssertXmlFileNotEqualsXmlFile() |
|
896
|
|
|
{ |
|
897
|
|
|
$this->assertXmlFileNotEqualsXmlFile( |
|
898
|
|
|
$this->filesDirectory . 'foo.xml', |
|
899
|
|
|
$this->filesDirectory . 'bar.xml' |
|
900
|
|
|
); |
|
901
|
|
|
|
|
902
|
|
|
$this->expectException(AssertionFailedError::class); |
|
903
|
|
|
|
|
904
|
|
|
$this->assertXmlFileNotEqualsXmlFile( |
|
905
|
|
|
$this->filesDirectory . 'foo.xml', |
|
906
|
|
|
$this->filesDirectory . 'foo.xml' |
|
907
|
|
|
); |
|
908
|
|
|
} |
|
909
|
|
|
|
|
910
|
|
|
public function testAssertXmlStringEqualsXmlFile() |
|
911
|
|
|
{ |
|
912
|
|
|
$this->assertXmlStringEqualsXmlFile( |
|
913
|
|
|
$this->filesDirectory . 'foo.xml', |
|
914
|
|
|
\file_get_contents($this->filesDirectory . 'foo.xml') |
|
915
|
|
|
); |
|
916
|
|
|
|
|
917
|
|
|
$this->expectException(AssertionFailedError::class); |
|
918
|
|
|
|
|
919
|
|
|
$this->assertXmlStringEqualsXmlFile( |
|
920
|
|
|
$this->filesDirectory . 'foo.xml', |
|
921
|
|
|
\file_get_contents($this->filesDirectory . 'bar.xml') |
|
922
|
|
|
); |
|
923
|
|
|
} |
|
924
|
|
|
|
|
925
|
|
|
public function testXmlStringNotEqualsXmlFile() |
|
926
|
|
|
{ |
|
927
|
|
|
$this->assertXmlStringNotEqualsXmlFile( |
|
928
|
|
|
$this->filesDirectory . 'foo.xml', |
|
929
|
|
|
\file_get_contents($this->filesDirectory . 'bar.xml') |
|
930
|
|
|
); |
|
931
|
|
|
|
|
932
|
|
|
$this->expectException(AssertionFailedError::class); |
|
933
|
|
|
|
|
934
|
|
|
$this->assertXmlStringNotEqualsXmlFile( |
|
935
|
|
|
$this->filesDirectory . 'foo.xml', |
|
936
|
|
|
\file_get_contents($this->filesDirectory . 'foo.xml') |
|
937
|
|
|
); |
|
938
|
|
|
} |
|
939
|
|
|
|
|
940
|
|
|
public function testAssertXmlStringEqualsXmlString() |
|
941
|
|
|
{ |
|
942
|
|
|
$this->assertXmlStringEqualsXmlString('<root/>', '<root/>'); |
|
943
|
|
|
|
|
944
|
|
|
$this->expectException(AssertionFailedError::class); |
|
945
|
|
|
|
|
946
|
|
|
$this->assertXmlStringEqualsXmlString('<foo/>', '<bar/>'); |
|
947
|
|
|
} |
|
948
|
|
|
|
|
949
|
|
|
/** |
|
950
|
|
|
* @ticket 1860 |
|
951
|
|
|
*/ |
|
952
|
|
|
public function testAssertXmlStringEqualsXmlString2() |
|
953
|
|
|
{ |
|
954
|
|
|
$this->expectException(Exception::class); |
|
955
|
|
|
|
|
956
|
|
|
$this->assertXmlStringEqualsXmlString('<a></b>', '<c></d>'); |
|
957
|
|
|
} |
|
958
|
|
|
|
|
959
|
|
|
/** |
|
960
|
|
|
* @ticket 1860 |
|
961
|
|
|
*/ |
|
962
|
|
|
public function testAssertXmlStringEqualsXmlString3() |
|
963
|
|
|
{ |
|
964
|
|
|
$expected = <<<XML |
|
965
|
|
|
<?xml version="1.0"?> |
|
966
|
|
|
<root> |
|
967
|
|
|
<node /> |
|
968
|
|
|
</root> |
|
969
|
|
|
XML; |
|
970
|
|
|
|
|
971
|
|
|
$actual = <<<XML |
|
972
|
|
|
<?xml version="1.0"?> |
|
973
|
|
|
<root> |
|
974
|
|
|
<node /> |
|
975
|
|
|
</root> |
|
976
|
|
|
XML; |
|
977
|
|
|
|
|
978
|
|
|
$this->assertXmlStringEqualsXmlString($expected, $actual); |
|
979
|
|
|
} |
|
980
|
|
|
|
|
981
|
|
|
public function testAssertXmlStringNotEqualsXmlString() |
|
982
|
|
|
{ |
|
983
|
|
|
$this->assertXmlStringNotEqualsXmlString('<foo/>', '<bar/>'); |
|
984
|
|
|
|
|
985
|
|
|
$this->expectException(AssertionFailedError::class); |
|
986
|
|
|
|
|
987
|
|
|
$this->assertXmlStringNotEqualsXmlString('<root/>', '<root/>'); |
|
988
|
|
|
} |
|
989
|
|
|
|
|
990
|
|
|
public function testXMLStructureIsSame() |
|
991
|
|
|
{ |
|
992
|
|
|
$expected = new \DOMDocument; |
|
993
|
|
|
$expected->load($this->filesDirectory . 'structureExpected.xml'); |
|
994
|
|
|
|
|
995
|
|
|
$actual = new \DOMDocument; |
|
996
|
|
|
$actual->load($this->filesDirectory . 'structureExpected.xml'); |
|
997
|
|
|
|
|
998
|
|
|
$this->assertEqualXMLStructure( |
|
999
|
|
|
$expected->firstChild, |
|
|
|
|
|
|
1000
|
|
|
$actual->firstChild, |
|
|
|
|
|
|
1001
|
|
|
true |
|
1002
|
|
|
); |
|
1003
|
|
|
} |
|
1004
|
|
|
|
|
1005
|
|
|
public function testXMLStructureWrongNumberOfAttributes() |
|
1006
|
|
|
{ |
|
1007
|
|
|
$expected = new \DOMDocument; |
|
1008
|
|
|
$expected->load($this->filesDirectory . 'structureExpected.xml'); |
|
1009
|
|
|
|
|
1010
|
|
|
$actual = new \DOMDocument; |
|
1011
|
|
|
$actual->load($this->filesDirectory . 'structureWrongNumberOfAttributes.xml'); |
|
1012
|
|
|
|
|
1013
|
|
|
$this->expectException(ExpectationFailedException::class); |
|
1014
|
|
|
|
|
1015
|
|
|
$this->assertEqualXMLStructure( |
|
1016
|
|
|
$expected->firstChild, |
|
|
|
|
|
|
1017
|
|
|
$actual->firstChild, |
|
|
|
|
|
|
1018
|
|
|
true |
|
1019
|
|
|
); |
|
1020
|
|
|
} |
|
1021
|
|
|
|
|
1022
|
|
|
public function testXMLStructureWrongNumberOfNodes() |
|
1023
|
|
|
{ |
|
1024
|
|
|
$expected = new \DOMDocument; |
|
1025
|
|
|
$expected->load($this->filesDirectory . 'structureExpected.xml'); |
|
1026
|
|
|
|
|
1027
|
|
|
$actual = new \DOMDocument; |
|
1028
|
|
|
$actual->load($this->filesDirectory . 'structureWrongNumberOfNodes.xml'); |
|
1029
|
|
|
|
|
1030
|
|
|
$this->expectException(ExpectationFailedException::class); |
|
1031
|
|
|
|
|
1032
|
|
|
$this->assertEqualXMLStructure( |
|
1033
|
|
|
$expected->firstChild, |
|
|
|
|
|
|
1034
|
|
|
$actual->firstChild, |
|
|
|
|
|
|
1035
|
|
|
true |
|
1036
|
|
|
); |
|
1037
|
|
|
} |
|
1038
|
|
|
|
|
1039
|
|
|
public function testXMLStructureIsSameButDataIsNot() |
|
1040
|
|
|
{ |
|
1041
|
|
|
$expected = new \DOMDocument; |
|
1042
|
|
|
$expected->load($this->filesDirectory . 'structureExpected.xml'); |
|
1043
|
|
|
|
|
1044
|
|
|
$actual = new \DOMDocument; |
|
1045
|
|
|
$actual->load($this->filesDirectory . 'structureIsSameButDataIsNot.xml'); |
|
1046
|
|
|
|
|
1047
|
|
|
$this->assertEqualXMLStructure( |
|
1048
|
|
|
$expected->firstChild, |
|
|
|
|
|
|
1049
|
|
|
$actual->firstChild, |
|
|
|
|
|
|
1050
|
|
|
true |
|
1051
|
|
|
); |
|
1052
|
|
|
} |
|
1053
|
|
|
|
|
1054
|
|
|
public function testXMLStructureAttributesAreSameButValuesAreNot() |
|
1055
|
|
|
{ |
|
1056
|
|
|
$expected = new \DOMDocument; |
|
1057
|
|
|
$expected->load($this->filesDirectory . 'structureExpected.xml'); |
|
1058
|
|
|
|
|
1059
|
|
|
$actual = new \DOMDocument; |
|
1060
|
|
|
$actual->load($this->filesDirectory . 'structureAttributesAreSameButValuesAreNot.xml'); |
|
1061
|
|
|
|
|
1062
|
|
|
$this->assertEqualXMLStructure( |
|
1063
|
|
|
$expected->firstChild, |
|
|
|
|
|
|
1064
|
|
|
$actual->firstChild, |
|
|
|
|
|
|
1065
|
|
|
true |
|
1066
|
|
|
); |
|
1067
|
|
|
} |
|
1068
|
|
|
|
|
1069
|
|
|
public function testXMLStructureIgnoreTextNodes() |
|
1070
|
|
|
{ |
|
1071
|
|
|
$expected = new \DOMDocument; |
|
1072
|
|
|
$expected->load($this->filesDirectory . 'structureExpected.xml'); |
|
1073
|
|
|
|
|
1074
|
|
|
$actual = new \DOMDocument; |
|
1075
|
|
|
$actual->load($this->filesDirectory . 'structureIgnoreTextNodes.xml'); |
|
1076
|
|
|
|
|
1077
|
|
|
$this->assertEqualXMLStructure( |
|
1078
|
|
|
$expected->firstChild, |
|
|
|
|
|
|
1079
|
|
|
$actual->firstChild, |
|
|
|
|
|
|
1080
|
|
|
true |
|
1081
|
|
|
); |
|
1082
|
|
|
} |
|
1083
|
|
|
|
|
1084
|
|
|
public function testAssertStringEqualsNumeric() |
|
1085
|
|
|
{ |
|
1086
|
|
|
$this->assertEquals('0', 0); |
|
1087
|
|
|
|
|
1088
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1089
|
|
|
|
|
1090
|
|
|
$this->assertEquals('0', 1); |
|
1091
|
|
|
} |
|
1092
|
|
|
|
|
1093
|
|
|
public function testAssertStringEqualsNumeric2() |
|
1094
|
|
|
{ |
|
1095
|
|
|
$this->assertNotEquals('A', 0); |
|
1096
|
|
|
} |
|
1097
|
|
|
|
|
1098
|
|
|
public function testAssertIsReadableThrowsException() |
|
1099
|
|
|
{ |
|
1100
|
|
|
$this->expectException(Exception::class); |
|
1101
|
|
|
|
|
1102
|
|
|
$this->assertIsReadable(null); |
|
1103
|
|
|
} |
|
1104
|
|
|
|
|
1105
|
|
|
public function testAssertIsReadable() |
|
1106
|
|
|
{ |
|
1107
|
|
|
$this->assertIsReadable(__FILE__); |
|
1108
|
|
|
|
|
1109
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1110
|
|
|
|
|
1111
|
|
|
$this->assertIsReadable(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1112
|
|
|
} |
|
1113
|
|
|
|
|
1114
|
|
|
public function testAssertNotIsReadableThrowsException() |
|
1115
|
|
|
{ |
|
1116
|
|
|
$this->expectException(Exception::class); |
|
1117
|
|
|
|
|
1118
|
|
|
$this->assertNotIsReadable(null); |
|
1119
|
|
|
} |
|
1120
|
|
|
|
|
1121
|
|
|
public function testAssertNotIsReadable() |
|
1122
|
|
|
{ |
|
1123
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1124
|
|
|
|
|
1125
|
|
|
$this->assertNotIsReadable(__FILE__); |
|
1126
|
|
|
} |
|
1127
|
|
|
|
|
1128
|
|
|
public function testAssertIsWritableThrowsException() |
|
1129
|
|
|
{ |
|
1130
|
|
|
$this->expectException(Exception::class); |
|
1131
|
|
|
|
|
1132
|
|
|
$this->assertIsWritable(null); |
|
1133
|
|
|
} |
|
1134
|
|
|
|
|
1135
|
|
|
public function testAssertIsWritable() |
|
1136
|
|
|
{ |
|
1137
|
|
|
$this->assertIsWritable(__FILE__); |
|
1138
|
|
|
|
|
1139
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1140
|
|
|
|
|
1141
|
|
|
$this->assertIsWritable(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1142
|
|
|
} |
|
1143
|
|
|
|
|
1144
|
|
|
public function testAssertNotIsWritableThrowsException() |
|
1145
|
|
|
{ |
|
1146
|
|
|
$this->expectException(Exception::class); |
|
1147
|
|
|
|
|
1148
|
|
|
$this->assertNotIsWritable(null); |
|
1149
|
|
|
} |
|
1150
|
|
|
|
|
1151
|
|
|
public function testAssertNotIsWritable() |
|
1152
|
|
|
{ |
|
1153
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1154
|
|
|
|
|
1155
|
|
|
$this->assertNotIsWritable(__FILE__); |
|
1156
|
|
|
} |
|
1157
|
|
|
|
|
1158
|
|
|
public function testAssertDirectoryExistsThrowsException() |
|
1159
|
|
|
{ |
|
1160
|
|
|
$this->expectException(Exception::class); |
|
1161
|
|
|
|
|
1162
|
|
|
$this->assertDirectoryExists(null); |
|
1163
|
|
|
} |
|
1164
|
|
|
|
|
1165
|
|
|
public function testAssertDirectoryExists() |
|
1166
|
|
|
{ |
|
1167
|
|
|
$this->assertDirectoryExists(__DIR__); |
|
1168
|
|
|
|
|
1169
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1170
|
|
|
|
|
1171
|
|
|
$this->assertDirectoryExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1172
|
|
|
} |
|
1173
|
|
|
|
|
1174
|
|
|
public function testAssertDirectoryNotExistsThrowsException() |
|
1175
|
|
|
{ |
|
1176
|
|
|
$this->expectException(Exception::class); |
|
1177
|
|
|
|
|
1178
|
|
|
$this->assertDirectoryNotExists(null); |
|
1179
|
|
|
} |
|
1180
|
|
|
|
|
1181
|
|
|
public function testAssertDirectoryNotExists() |
|
1182
|
|
|
{ |
|
1183
|
|
|
$this->assertDirectoryNotExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1184
|
|
|
|
|
1185
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1186
|
|
|
|
|
1187
|
|
|
$this->assertDirectoryNotExists(__DIR__); |
|
1188
|
|
|
} |
|
1189
|
|
|
|
|
1190
|
|
|
public function testAssertDirectoryIsReadableThrowsException() |
|
1191
|
|
|
{ |
|
1192
|
|
|
$this->expectException(Exception::class); |
|
1193
|
|
|
|
|
1194
|
|
|
$this->assertDirectoryIsReadable(null); |
|
1195
|
|
|
} |
|
1196
|
|
|
|
|
1197
|
|
|
public function testAssertDirectoryIsReadable() |
|
1198
|
|
|
{ |
|
1199
|
|
|
$this->assertDirectoryIsReadable(__DIR__); |
|
1200
|
|
|
|
|
1201
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1202
|
|
|
|
|
1203
|
|
|
$this->assertDirectoryIsReadable(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1204
|
|
|
} |
|
1205
|
|
|
|
|
1206
|
|
|
public function testAssertDirectoryNotIsReadableThrowsException() |
|
1207
|
|
|
{ |
|
1208
|
|
|
$this->expectException(Exception::class); |
|
1209
|
|
|
|
|
1210
|
|
|
$this->assertDirectoryNotIsReadable(null); |
|
1211
|
|
|
} |
|
1212
|
|
|
|
|
1213
|
|
|
public function testAssertDirectoryIsWritableThrowsException() |
|
1214
|
|
|
{ |
|
1215
|
|
|
$this->expectException(Exception::class); |
|
1216
|
|
|
|
|
1217
|
|
|
$this->assertDirectoryIsWritable(null); |
|
1218
|
|
|
} |
|
1219
|
|
|
|
|
1220
|
|
|
public function testAssertDirectoryIsWritable() |
|
1221
|
|
|
{ |
|
1222
|
|
|
$this->assertDirectoryIsWritable(__DIR__); |
|
1223
|
|
|
|
|
1224
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1225
|
|
|
|
|
1226
|
|
|
$this->assertDirectoryIsWritable(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1227
|
|
|
} |
|
1228
|
|
|
|
|
1229
|
|
|
public function testAssertDirectoryNotIsWritableThrowsException() |
|
1230
|
|
|
{ |
|
1231
|
|
|
$this->expectException(Exception::class); |
|
1232
|
|
|
|
|
1233
|
|
|
$this->assertDirectoryNotIsWritable(null); |
|
1234
|
|
|
} |
|
1235
|
|
|
|
|
1236
|
|
|
public function testAssertFileExistsThrowsException() |
|
1237
|
|
|
{ |
|
1238
|
|
|
$this->expectException(Exception::class); |
|
1239
|
|
|
|
|
1240
|
|
|
$this->assertFileExists(null); |
|
1241
|
|
|
} |
|
1242
|
|
|
|
|
1243
|
|
|
public function testAssertFileExists() |
|
1244
|
|
|
{ |
|
1245
|
|
|
$this->assertFileExists(__FILE__); |
|
1246
|
|
|
|
|
1247
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1248
|
|
|
|
|
1249
|
|
|
$this->assertFileExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1250
|
|
|
} |
|
1251
|
|
|
|
|
1252
|
|
|
public function testAssertFileNotExistsThrowsException() |
|
1253
|
|
|
{ |
|
1254
|
|
|
$this->expectException(Exception::class); |
|
1255
|
|
|
|
|
1256
|
|
|
$this->assertFileNotExists(null); |
|
1257
|
|
|
} |
|
1258
|
|
|
|
|
1259
|
|
|
public function testAssertFileNotExists() |
|
1260
|
|
|
{ |
|
1261
|
|
|
$this->assertFileNotExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1262
|
|
|
|
|
1263
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1264
|
|
|
|
|
1265
|
|
|
$this->assertFileNotExists(__FILE__); |
|
1266
|
|
|
} |
|
1267
|
|
|
|
|
1268
|
|
|
public function testAssertFileIsReadableThrowsException() |
|
1269
|
|
|
{ |
|
1270
|
|
|
$this->expectException(Exception::class); |
|
1271
|
|
|
|
|
1272
|
|
|
$this->assertFileIsReadable(null); |
|
1273
|
|
|
} |
|
1274
|
|
|
|
|
1275
|
|
|
public function testAssertFileIsReadable() |
|
1276
|
|
|
{ |
|
1277
|
|
|
$this->assertFileIsReadable(__FILE__); |
|
1278
|
|
|
|
|
1279
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1280
|
|
|
|
|
1281
|
|
|
$this->assertFileIsReadable(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1282
|
|
|
} |
|
1283
|
|
|
|
|
1284
|
|
|
public function testAssertFileNotIsReadableThrowsException() |
|
1285
|
|
|
{ |
|
1286
|
|
|
$this->expectException(Exception::class); |
|
1287
|
|
|
|
|
1288
|
|
|
$this->assertFileNotIsReadable(null); |
|
1289
|
|
|
} |
|
1290
|
|
|
|
|
1291
|
|
|
public function testAssertFileIsWritableThrowsException() |
|
1292
|
|
|
{ |
|
1293
|
|
|
$this->expectException(Exception::class); |
|
1294
|
|
|
|
|
1295
|
|
|
$this->assertFileIsWritable(null); |
|
1296
|
|
|
} |
|
1297
|
|
|
|
|
1298
|
|
|
public function testAssertFileIsWritable() |
|
1299
|
|
|
{ |
|
1300
|
|
|
$this->assertFileIsWritable(__FILE__); |
|
1301
|
|
|
|
|
1302
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1303
|
|
|
|
|
1304
|
|
|
$this->assertFileIsWritable(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
|
1305
|
|
|
} |
|
1306
|
|
|
|
|
1307
|
|
|
public function testAssertFileNotIsWritableThrowsException() |
|
1308
|
|
|
{ |
|
1309
|
|
|
$this->expectException(Exception::class); |
|
1310
|
|
|
|
|
1311
|
|
|
$this->assertFileNotIsWritable(null); |
|
1312
|
|
|
} |
|
1313
|
|
|
|
|
1314
|
|
|
public function testAssertObjectHasAttribute() |
|
1315
|
|
|
{ |
|
1316
|
|
|
$o = new \Author('Terry Pratchett'); |
|
1317
|
|
|
|
|
1318
|
|
|
$this->assertObjectHasAttribute('name', $o); |
|
1319
|
|
|
|
|
1320
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1321
|
|
|
|
|
1322
|
|
|
$this->assertObjectHasAttribute('foo', $o); |
|
1323
|
|
|
} |
|
1324
|
|
|
|
|
1325
|
|
|
public function testAssertObjectNotHasAttribute() |
|
1326
|
|
|
{ |
|
1327
|
|
|
$o = new \Author('Terry Pratchett'); |
|
1328
|
|
|
|
|
1329
|
|
|
$this->assertObjectNotHasAttribute('foo', $o); |
|
1330
|
|
|
|
|
1331
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1332
|
|
|
|
|
1333
|
|
|
$this->assertObjectNotHasAttribute('name', $o); |
|
1334
|
|
|
} |
|
1335
|
|
|
|
|
1336
|
|
|
public function testAssertFinite() |
|
1337
|
|
|
{ |
|
1338
|
|
|
$this->assertFinite(1); |
|
1339
|
|
|
|
|
1340
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1341
|
|
|
|
|
1342
|
|
|
$this->assertFinite(INF); |
|
1343
|
|
|
} |
|
1344
|
|
|
|
|
1345
|
|
|
public function testAssertInfinite() |
|
1346
|
|
|
{ |
|
1347
|
|
|
$this->assertInfinite(INF); |
|
1348
|
|
|
|
|
1349
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1350
|
|
|
|
|
1351
|
|
|
$this->assertInfinite(1); |
|
1352
|
|
|
} |
|
1353
|
|
|
|
|
1354
|
|
|
public function testAssertNan() |
|
1355
|
|
|
{ |
|
1356
|
|
|
$this->assertNan(NAN); |
|
1357
|
|
|
|
|
1358
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1359
|
|
|
|
|
1360
|
|
|
$this->assertNan(1); |
|
1361
|
|
|
} |
|
1362
|
|
|
|
|
1363
|
|
|
public function testAssertNull() |
|
1364
|
|
|
{ |
|
1365
|
|
|
$this->assertNull(null); |
|
1366
|
|
|
|
|
1367
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1368
|
|
|
|
|
1369
|
|
|
$this->assertNull(new \stdClass); |
|
1370
|
|
|
} |
|
1371
|
|
|
|
|
1372
|
|
|
public function testAssertNotNull() |
|
1373
|
|
|
{ |
|
1374
|
|
|
$this->assertNotNull(new \stdClass); |
|
1375
|
|
|
|
|
1376
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1377
|
|
|
|
|
1378
|
|
|
$this->assertNotNull(null); |
|
1379
|
|
|
} |
|
1380
|
|
|
|
|
1381
|
|
|
public function testAssertTrue() |
|
1382
|
|
|
{ |
|
1383
|
|
|
$this->assertTrue(true); |
|
1384
|
|
|
|
|
1385
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1386
|
|
|
|
|
1387
|
|
|
$this->assertTrue(false); |
|
1388
|
|
|
} |
|
1389
|
|
|
|
|
1390
|
|
|
public function testAssertNotTrue() |
|
1391
|
|
|
{ |
|
1392
|
|
|
$this->assertNotTrue(false); |
|
1393
|
|
|
$this->assertNotTrue(1); |
|
|
|
|
|
|
1394
|
|
|
$this->assertNotTrue('true'); |
|
|
|
|
|
|
1395
|
|
|
|
|
1396
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1397
|
|
|
|
|
1398
|
|
|
$this->assertNotTrue(true); |
|
1399
|
|
|
} |
|
1400
|
|
|
|
|
1401
|
|
|
public function testAssertFalse() |
|
1402
|
|
|
{ |
|
1403
|
|
|
$this->assertFalse(false); |
|
1404
|
|
|
|
|
1405
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1406
|
|
|
|
|
1407
|
|
|
$this->assertFalse(true); |
|
1408
|
|
|
} |
|
1409
|
|
|
|
|
1410
|
|
|
public function testAssertNotFalse() |
|
1411
|
|
|
{ |
|
1412
|
|
|
$this->assertNotFalse(true); |
|
1413
|
|
|
$this->assertNotFalse(0); |
|
|
|
|
|
|
1414
|
|
|
$this->assertNotFalse(''); |
|
|
|
|
|
|
1415
|
|
|
|
|
1416
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1417
|
|
|
|
|
1418
|
|
|
$this->assertNotFalse(false); |
|
1419
|
|
|
} |
|
1420
|
|
|
|
|
1421
|
|
|
public function testAssertRegExpThrowsException() |
|
1422
|
|
|
{ |
|
1423
|
|
|
$this->expectException(Exception::class); |
|
1424
|
|
|
|
|
1425
|
|
|
$this->assertRegExp(null, null); |
|
1426
|
|
|
} |
|
1427
|
|
|
|
|
1428
|
|
|
public function testAssertRegExpThrowsException2() |
|
1429
|
|
|
{ |
|
1430
|
|
|
$this->expectException(Exception::class); |
|
1431
|
|
|
|
|
1432
|
|
|
$this->assertRegExp('', null); |
|
1433
|
|
|
} |
|
1434
|
|
|
|
|
1435
|
|
|
public function testAssertNotRegExpThrowsException() |
|
1436
|
|
|
{ |
|
1437
|
|
|
$this->expectException(Exception::class); |
|
1438
|
|
|
|
|
1439
|
|
|
$this->assertNotRegExp(null, null); |
|
1440
|
|
|
} |
|
1441
|
|
|
|
|
1442
|
|
|
public function testAssertNotRegExpThrowsException2() |
|
1443
|
|
|
{ |
|
1444
|
|
|
$this->expectException(Exception::class); |
|
1445
|
|
|
|
|
1446
|
|
|
$this->assertNotRegExp('', null); |
|
1447
|
|
|
} |
|
1448
|
|
|
|
|
1449
|
|
|
public function testAssertRegExp() |
|
1450
|
|
|
{ |
|
1451
|
|
|
$this->assertRegExp('/foo/', 'foobar'); |
|
1452
|
|
|
|
|
1453
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1454
|
|
|
|
|
1455
|
|
|
$this->assertRegExp('/foo/', 'bar'); |
|
1456
|
|
|
} |
|
1457
|
|
|
|
|
1458
|
|
|
public function testAssertNotRegExp() |
|
1459
|
|
|
{ |
|
1460
|
|
|
$this->assertNotRegExp('/foo/', 'bar'); |
|
1461
|
|
|
|
|
1462
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1463
|
|
|
|
|
1464
|
|
|
$this->assertNotRegExp('/foo/', 'foobar'); |
|
1465
|
|
|
} |
|
1466
|
|
|
|
|
1467
|
|
|
public function testAssertSame() |
|
1468
|
|
|
{ |
|
1469
|
|
|
$o = new \stdClass; |
|
1470
|
|
|
|
|
1471
|
|
|
$this->assertSame($o, $o); |
|
1472
|
|
|
|
|
1473
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1474
|
|
|
|
|
1475
|
|
|
$this->assertSame(new \stdClass, new \stdClass); |
|
1476
|
|
|
} |
|
1477
|
|
|
|
|
1478
|
|
|
public function testAssertSame2() |
|
1479
|
|
|
{ |
|
1480
|
|
|
$this->assertSame(true, true); |
|
1481
|
|
|
$this->assertSame(false, false); |
|
1482
|
|
|
|
|
1483
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1484
|
|
|
|
|
1485
|
|
|
$this->assertSame(true, false); |
|
1486
|
|
|
} |
|
1487
|
|
|
|
|
1488
|
|
|
public function testAssertNotSame() |
|
1489
|
|
|
{ |
|
1490
|
|
|
$this->assertNotSame( |
|
1491
|
|
|
new \stdClass, |
|
1492
|
|
|
null |
|
1493
|
|
|
); |
|
1494
|
|
|
|
|
1495
|
|
|
$this->assertNotSame( |
|
1496
|
|
|
null, |
|
1497
|
|
|
new \stdClass |
|
1498
|
|
|
); |
|
1499
|
|
|
|
|
1500
|
|
|
$this->assertNotSame( |
|
1501
|
|
|
new \stdClass, |
|
1502
|
|
|
new \stdClass |
|
1503
|
|
|
); |
|
1504
|
|
|
|
|
1505
|
|
|
$o = new \stdClass; |
|
1506
|
|
|
|
|
1507
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1508
|
|
|
|
|
1509
|
|
|
$this->assertNotSame($o, $o); |
|
1510
|
|
|
} |
|
1511
|
|
|
|
|
1512
|
|
|
public function testAssertNotSame2() |
|
1513
|
|
|
{ |
|
1514
|
|
|
$this->assertNotSame(true, false); |
|
1515
|
|
|
$this->assertNotSame(false, true); |
|
1516
|
|
|
|
|
1517
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1518
|
|
|
|
|
1519
|
|
|
$this->assertNotSame(true, true); |
|
1520
|
|
|
} |
|
1521
|
|
|
|
|
1522
|
|
|
public function testAssertNotSameFailsNull() |
|
1523
|
|
|
{ |
|
1524
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1525
|
|
|
|
|
1526
|
|
|
$this->assertNotSame(null, null); |
|
1527
|
|
|
} |
|
1528
|
|
|
|
|
1529
|
|
|
public function testGreaterThan() |
|
1530
|
|
|
{ |
|
1531
|
|
|
$this->assertGreaterThan(1, 2); |
|
1532
|
|
|
|
|
1533
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1534
|
|
|
|
|
1535
|
|
|
$this->assertGreaterThan(2, 1); |
|
1536
|
|
|
} |
|
1537
|
|
|
|
|
1538
|
|
|
public function testAttributeGreaterThan() |
|
1539
|
|
|
{ |
|
1540
|
|
|
$this->assertAttributeGreaterThan( |
|
1541
|
|
|
1, |
|
1542
|
|
|
'bar', |
|
1543
|
|
|
new \ClassWithNonPublicAttributes |
|
1544
|
|
|
); |
|
1545
|
|
|
|
|
1546
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1547
|
|
|
|
|
1548
|
|
|
$this->assertAttributeGreaterThan( |
|
1549
|
|
|
1, |
|
1550
|
|
|
'foo', |
|
1551
|
|
|
new \ClassWithNonPublicAttributes |
|
1552
|
|
|
); |
|
1553
|
|
|
} |
|
1554
|
|
|
|
|
1555
|
|
|
public function testGreaterThanOrEqual() |
|
1556
|
|
|
{ |
|
1557
|
|
|
$this->assertGreaterThanOrEqual(1, 2); |
|
1558
|
|
|
|
|
1559
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1560
|
|
|
|
|
1561
|
|
|
$this->assertGreaterThanOrEqual(2, 1); |
|
1562
|
|
|
} |
|
1563
|
|
|
|
|
1564
|
|
|
public function testAttributeGreaterThanOrEqual() |
|
1565
|
|
|
{ |
|
1566
|
|
|
$this->assertAttributeGreaterThanOrEqual( |
|
1567
|
|
|
1, |
|
1568
|
|
|
'bar', |
|
1569
|
|
|
new \ClassWithNonPublicAttributes |
|
1570
|
|
|
); |
|
1571
|
|
|
|
|
1572
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1573
|
|
|
|
|
1574
|
|
|
$this->assertAttributeGreaterThanOrEqual( |
|
1575
|
|
|
2, |
|
1576
|
|
|
'foo', |
|
1577
|
|
|
new \ClassWithNonPublicAttributes |
|
1578
|
|
|
); |
|
1579
|
|
|
} |
|
1580
|
|
|
|
|
1581
|
|
|
public function testLessThan() |
|
1582
|
|
|
{ |
|
1583
|
|
|
$this->assertLessThan(2, 1); |
|
1584
|
|
|
|
|
1585
|
|
|
try { |
|
1586
|
|
|
$this->assertLessThan(1, 2); |
|
1587
|
|
|
} catch (AssertionFailedError $e) { |
|
1588
|
|
|
return; |
|
1589
|
|
|
} |
|
1590
|
|
|
|
|
1591
|
|
|
$this->fail(); |
|
1592
|
|
|
} |
|
1593
|
|
|
|
|
1594
|
|
|
public function testAttributeLessThan() |
|
1595
|
|
|
{ |
|
1596
|
|
|
$this->assertAttributeLessThan( |
|
1597
|
|
|
2, |
|
1598
|
|
|
'foo', |
|
1599
|
|
|
new \ClassWithNonPublicAttributes |
|
1600
|
|
|
); |
|
1601
|
|
|
|
|
1602
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1603
|
|
|
|
|
1604
|
|
|
$this->assertAttributeLessThan( |
|
1605
|
|
|
1, |
|
1606
|
|
|
'bar', |
|
1607
|
|
|
new \ClassWithNonPublicAttributes |
|
1608
|
|
|
); |
|
1609
|
|
|
} |
|
1610
|
|
|
|
|
1611
|
|
|
public function testLessThanOrEqual() |
|
1612
|
|
|
{ |
|
1613
|
|
|
$this->assertLessThanOrEqual(2, 1); |
|
1614
|
|
|
|
|
1615
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1616
|
|
|
|
|
1617
|
|
|
$this->assertLessThanOrEqual(1, 2); |
|
1618
|
|
|
} |
|
1619
|
|
|
|
|
1620
|
|
|
public function testAttributeLessThanOrEqual() |
|
1621
|
|
|
{ |
|
1622
|
|
|
$this->assertAttributeLessThanOrEqual( |
|
1623
|
|
|
2, |
|
1624
|
|
|
'foo', |
|
1625
|
|
|
new \ClassWithNonPublicAttributes |
|
1626
|
|
|
); |
|
1627
|
|
|
|
|
1628
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1629
|
|
|
|
|
1630
|
|
|
$this->assertAttributeLessThanOrEqual( |
|
1631
|
|
|
1, |
|
1632
|
|
|
'bar', |
|
1633
|
|
|
new \ClassWithNonPublicAttributes |
|
1634
|
|
|
); |
|
1635
|
|
|
} |
|
1636
|
|
|
|
|
1637
|
|
|
public function testReadAttribute() |
|
1638
|
|
|
{ |
|
1639
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1640
|
|
|
|
|
1641
|
|
|
$this->assertEquals('foo', $this->readAttribute($obj, 'publicAttribute')); |
|
1642
|
|
|
$this->assertEquals('bar', $this->readAttribute($obj, 'protectedAttribute')); |
|
1643
|
|
|
$this->assertEquals('baz', $this->readAttribute($obj, 'privateAttribute')); |
|
1644
|
|
|
$this->assertEquals('bar', $this->readAttribute($obj, 'protectedParentAttribute')); |
|
1645
|
|
|
//$this->assertEquals('bar', $this->readAttribute($obj, 'privateParentAttribute')); |
|
1646
|
|
|
} |
|
1647
|
|
|
|
|
1648
|
|
|
public function testReadAttribute2() |
|
1649
|
|
|
{ |
|
1650
|
|
|
$this->assertEquals('foo', $this->readAttribute(\ClassWithNonPublicAttributes::class, 'publicStaticAttribute')); |
|
1651
|
|
|
$this->assertEquals('bar', $this->readAttribute(\ClassWithNonPublicAttributes::class, 'protectedStaticAttribute')); |
|
1652
|
|
|
$this->assertEquals('baz', $this->readAttribute(\ClassWithNonPublicAttributes::class, 'privateStaticAttribute')); |
|
1653
|
|
|
$this->assertEquals('foo', $this->readAttribute(\ClassWithNonPublicAttributes::class, 'protectedStaticParentAttribute')); |
|
1654
|
|
|
$this->assertEquals('foo', $this->readAttribute(\ClassWithNonPublicAttributes::class, 'privateStaticParentAttribute')); |
|
1655
|
|
|
} |
|
1656
|
|
|
|
|
1657
|
|
|
public function testReadAttribute3() |
|
1658
|
|
|
{ |
|
1659
|
|
|
$this->expectException(Exception::class); |
|
1660
|
|
|
|
|
1661
|
|
|
$this->readAttribute('StdClass', null); |
|
1662
|
|
|
} |
|
1663
|
|
|
|
|
1664
|
|
|
public function testReadAttribute4() |
|
1665
|
|
|
{ |
|
1666
|
|
|
$this->expectException(Exception::class); |
|
1667
|
|
|
|
|
1668
|
|
|
$this->readAttribute('NotExistingClass', 'foo'); |
|
1669
|
|
|
} |
|
1670
|
|
|
|
|
1671
|
|
|
public function testReadAttribute5() |
|
1672
|
|
|
{ |
|
1673
|
|
|
$this->expectException(Exception::class); |
|
1674
|
|
|
|
|
1675
|
|
|
$this->readAttribute(null, 'foo'); |
|
1676
|
|
|
} |
|
1677
|
|
|
|
|
1678
|
|
|
public function testReadAttributeIfAttributeNameIsNotValid() |
|
1679
|
|
|
{ |
|
1680
|
|
|
$this->expectException(Exception::class); |
|
1681
|
|
|
|
|
1682
|
|
|
$this->readAttribute(\stdClass::class, '2'); |
|
1683
|
|
|
} |
|
1684
|
|
|
|
|
1685
|
|
|
public function testGetStaticAttributeRaisesExceptionForInvalidFirstArgument() |
|
1686
|
|
|
{ |
|
1687
|
|
|
$this->expectException(Exception::class); |
|
1688
|
|
|
|
|
1689
|
|
|
$this->getStaticAttribute(null, 'foo'); |
|
1690
|
|
|
} |
|
1691
|
|
|
|
|
1692
|
|
|
public function testGetStaticAttributeRaisesExceptionForInvalidFirstArgument2() |
|
1693
|
|
|
{ |
|
1694
|
|
|
$this->expectException(Exception::class); |
|
1695
|
|
|
|
|
1696
|
|
|
$this->getStaticAttribute('NotExistingClass', 'foo'); |
|
1697
|
|
|
} |
|
1698
|
|
|
|
|
1699
|
|
|
public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument() |
|
1700
|
|
|
{ |
|
1701
|
|
|
$this->expectException(Exception::class); |
|
1702
|
|
|
|
|
1703
|
|
|
$this->getStaticAttribute(\stdClass::class, null); |
|
1704
|
|
|
} |
|
1705
|
|
|
|
|
1706
|
|
|
public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument2() |
|
1707
|
|
|
{ |
|
1708
|
|
|
$this->expectException(Exception::class); |
|
1709
|
|
|
|
|
1710
|
|
|
$this->getStaticAttribute(\stdClass::class, '0'); |
|
1711
|
|
|
} |
|
1712
|
|
|
|
|
1713
|
|
|
public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument3() |
|
1714
|
|
|
{ |
|
1715
|
|
|
$this->expectException(Exception::class); |
|
1716
|
|
|
|
|
1717
|
|
|
$this->getStaticAttribute(\stdClass::class, 'foo'); |
|
1718
|
|
|
} |
|
1719
|
|
|
|
|
1720
|
|
|
public function testGetObjectAttributeRaisesExceptionForInvalidFirstArgument() |
|
1721
|
|
|
{ |
|
1722
|
|
|
$this->expectException(Exception::class); |
|
1723
|
|
|
|
|
1724
|
|
|
$this->getObjectAttribute(null, 'foo'); |
|
|
|
|
|
|
1725
|
|
|
} |
|
1726
|
|
|
|
|
1727
|
|
|
public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument() |
|
1728
|
|
|
{ |
|
1729
|
|
|
$this->expectException(Exception::class); |
|
1730
|
|
|
|
|
1731
|
|
|
$this->getObjectAttribute(new \stdClass, null); |
|
1732
|
|
|
} |
|
1733
|
|
|
|
|
1734
|
|
|
public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument2() |
|
1735
|
|
|
{ |
|
1736
|
|
|
$this->expectException(Exception::class); |
|
1737
|
|
|
|
|
1738
|
|
|
$this->getObjectAttribute(new \stdClass, '0'); |
|
1739
|
|
|
} |
|
1740
|
|
|
|
|
1741
|
|
|
public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument3() |
|
1742
|
|
|
{ |
|
1743
|
|
|
$this->expectException(Exception::class); |
|
1744
|
|
|
|
|
1745
|
|
|
$this->getObjectAttribute(new \stdClass, 'foo'); |
|
1746
|
|
|
} |
|
1747
|
|
|
|
|
1748
|
|
|
public function testGetObjectAttributeWorksForInheritedAttributes() |
|
1749
|
|
|
{ |
|
1750
|
|
|
$this->assertEquals( |
|
1751
|
|
|
'bar', |
|
1752
|
|
|
$this->getObjectAttribute(new \ClassWithNonPublicAttributes, 'privateParentAttribute') |
|
1753
|
|
|
); |
|
1754
|
|
|
} |
|
1755
|
|
|
|
|
1756
|
|
|
public function testAssertPublicAttributeContains() |
|
1757
|
|
|
{ |
|
1758
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1759
|
|
|
|
|
1760
|
|
|
$this->assertAttributeContains('foo', 'publicArray', $obj); |
|
1761
|
|
|
|
|
1762
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1763
|
|
|
|
|
1764
|
|
|
$this->assertAttributeContains('bar', 'publicArray', $obj); |
|
1765
|
|
|
} |
|
1766
|
|
|
|
|
1767
|
|
|
public function testAssertPublicAttributeContainsOnly() |
|
1768
|
|
|
{ |
|
1769
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1770
|
|
|
|
|
1771
|
|
|
$this->assertAttributeContainsOnly('string', 'publicArray', $obj); |
|
1772
|
|
|
|
|
1773
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1774
|
|
|
|
|
1775
|
|
|
$this->assertAttributeContainsOnly('integer', 'publicArray', $obj); |
|
1776
|
|
|
} |
|
1777
|
|
|
|
|
1778
|
|
|
public function testAssertPublicAttributeNotContains() |
|
1779
|
|
|
{ |
|
1780
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1781
|
|
|
|
|
1782
|
|
|
$this->assertAttributeNotContains('bar', 'publicArray', $obj); |
|
1783
|
|
|
|
|
1784
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1785
|
|
|
|
|
1786
|
|
|
$this->assertAttributeNotContains('foo', 'publicArray', $obj); |
|
1787
|
|
|
} |
|
1788
|
|
|
|
|
1789
|
|
|
public function testAssertPublicAttributeNotContainsOnly() |
|
1790
|
|
|
{ |
|
1791
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1792
|
|
|
|
|
1793
|
|
|
$this->assertAttributeNotContainsOnly('integer', 'publicArray', $obj); |
|
1794
|
|
|
|
|
1795
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1796
|
|
|
|
|
1797
|
|
|
$this->assertAttributeNotContainsOnly('string', 'publicArray', $obj); |
|
1798
|
|
|
} |
|
1799
|
|
|
|
|
1800
|
|
|
public function testAssertProtectedAttributeContains() |
|
1801
|
|
|
{ |
|
1802
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1803
|
|
|
|
|
1804
|
|
|
$this->assertAttributeContains('bar', 'protectedArray', $obj); |
|
1805
|
|
|
|
|
1806
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1807
|
|
|
|
|
1808
|
|
|
$this->assertAttributeContains('foo', 'protectedArray', $obj); |
|
1809
|
|
|
} |
|
1810
|
|
|
|
|
1811
|
|
|
public function testAssertProtectedAttributeNotContains() |
|
1812
|
|
|
{ |
|
1813
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1814
|
|
|
|
|
1815
|
|
|
$this->assertAttributeNotContains('foo', 'protectedArray', $obj); |
|
1816
|
|
|
|
|
1817
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1818
|
|
|
|
|
1819
|
|
|
$this->assertAttributeNotContains('bar', 'protectedArray', $obj); |
|
1820
|
|
|
} |
|
1821
|
|
|
|
|
1822
|
|
|
public function testAssertPrivateAttributeContains() |
|
1823
|
|
|
{ |
|
1824
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1825
|
|
|
|
|
1826
|
|
|
$this->assertAttributeContains('baz', 'privateArray', $obj); |
|
1827
|
|
|
|
|
1828
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1829
|
|
|
|
|
1830
|
|
|
$this->assertAttributeContains('foo', 'privateArray', $obj); |
|
1831
|
|
|
} |
|
1832
|
|
|
|
|
1833
|
|
|
public function testAssertPrivateAttributeNotContains() |
|
1834
|
|
|
{ |
|
1835
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1836
|
|
|
|
|
1837
|
|
|
$this->assertAttributeNotContains('foo', 'privateArray', $obj); |
|
1838
|
|
|
|
|
1839
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1840
|
|
|
|
|
1841
|
|
|
$this->assertAttributeNotContains('baz', 'privateArray', $obj); |
|
1842
|
|
|
} |
|
1843
|
|
|
|
|
1844
|
|
|
public function testAssertAttributeContainsNonObject() |
|
1845
|
|
|
{ |
|
1846
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1847
|
|
|
|
|
1848
|
|
|
$this->assertAttributeContains(true, 'privateArray', $obj); |
|
1849
|
|
|
|
|
1850
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1851
|
|
|
|
|
1852
|
|
|
$this->assertAttributeContains(true, 'privateArray', $obj, '', false, true, true); |
|
1853
|
|
|
} |
|
1854
|
|
|
|
|
1855
|
|
|
public function testAssertAttributeNotContainsNonObject() |
|
1856
|
|
|
{ |
|
1857
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1858
|
|
|
|
|
1859
|
|
|
$this->assertAttributeNotContains(true, 'privateArray', $obj, '', false, true, true); |
|
1860
|
|
|
|
|
1861
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1862
|
|
|
|
|
1863
|
|
|
$this->assertAttributeNotContains(true, 'privateArray', $obj); |
|
1864
|
|
|
} |
|
1865
|
|
|
|
|
1866
|
|
|
public function testAssertPublicAttributeEquals() |
|
1867
|
|
|
{ |
|
1868
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1869
|
|
|
|
|
1870
|
|
|
$this->assertAttributeEquals('foo', 'publicAttribute', $obj); |
|
1871
|
|
|
|
|
1872
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1873
|
|
|
|
|
1874
|
|
|
$this->assertAttributeEquals('bar', 'publicAttribute', $obj); |
|
1875
|
|
|
} |
|
1876
|
|
|
|
|
1877
|
|
|
public function testAssertPublicAttributeNotEquals() |
|
1878
|
|
|
{ |
|
1879
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1880
|
|
|
|
|
1881
|
|
|
$this->assertAttributeNotEquals('bar', 'publicAttribute', $obj); |
|
1882
|
|
|
|
|
1883
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1884
|
|
|
|
|
1885
|
|
|
$this->assertAttributeNotEquals('foo', 'publicAttribute', $obj); |
|
1886
|
|
|
} |
|
1887
|
|
|
|
|
1888
|
|
|
public function testAssertPublicAttributeSame() |
|
1889
|
|
|
{ |
|
1890
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1891
|
|
|
|
|
1892
|
|
|
$this->assertAttributeSame('foo', 'publicAttribute', $obj); |
|
1893
|
|
|
|
|
1894
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1895
|
|
|
|
|
1896
|
|
|
$this->assertAttributeSame('bar', 'publicAttribute', $obj); |
|
1897
|
|
|
} |
|
1898
|
|
|
|
|
1899
|
|
|
public function testAssertPublicAttributeNotSame() |
|
1900
|
|
|
{ |
|
1901
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1902
|
|
|
|
|
1903
|
|
|
$this->assertAttributeNotSame('bar', 'publicAttribute', $obj); |
|
1904
|
|
|
|
|
1905
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1906
|
|
|
|
|
1907
|
|
|
$this->assertAttributeNotSame('foo', 'publicAttribute', $obj); |
|
1908
|
|
|
} |
|
1909
|
|
|
|
|
1910
|
|
|
public function testAssertProtectedAttributeEquals() |
|
1911
|
|
|
{ |
|
1912
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1913
|
|
|
|
|
1914
|
|
|
$this->assertAttributeEquals('bar', 'protectedAttribute', $obj); |
|
1915
|
|
|
|
|
1916
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1917
|
|
|
|
|
1918
|
|
|
$this->assertAttributeEquals('foo', 'protectedAttribute', $obj); |
|
1919
|
|
|
} |
|
1920
|
|
|
|
|
1921
|
|
|
public function testAssertProtectedAttributeNotEquals() |
|
1922
|
|
|
{ |
|
1923
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1924
|
|
|
|
|
1925
|
|
|
$this->assertAttributeNotEquals('foo', 'protectedAttribute', $obj); |
|
1926
|
|
|
|
|
1927
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1928
|
|
|
|
|
1929
|
|
|
$this->assertAttributeNotEquals('bar', 'protectedAttribute', $obj); |
|
1930
|
|
|
} |
|
1931
|
|
|
|
|
1932
|
|
|
public function testAssertPrivateAttributeEquals() |
|
1933
|
|
|
{ |
|
1934
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1935
|
|
|
|
|
1936
|
|
|
$this->assertAttributeEquals('baz', 'privateAttribute', $obj); |
|
1937
|
|
|
|
|
1938
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1939
|
|
|
|
|
1940
|
|
|
$this->assertAttributeEquals('foo', 'privateAttribute', $obj); |
|
1941
|
|
|
} |
|
1942
|
|
|
|
|
1943
|
|
|
public function testAssertPrivateAttributeNotEquals() |
|
1944
|
|
|
{ |
|
1945
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
1946
|
|
|
|
|
1947
|
|
|
$this->assertAttributeNotEquals('foo', 'privateAttribute', $obj); |
|
1948
|
|
|
|
|
1949
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1950
|
|
|
|
|
1951
|
|
|
$this->assertAttributeNotEquals('baz', 'privateAttribute', $obj); |
|
1952
|
|
|
} |
|
1953
|
|
|
|
|
1954
|
|
|
public function testAssertPublicStaticAttributeEquals() |
|
1955
|
|
|
{ |
|
1956
|
|
|
$this->assertAttributeEquals('foo', 'publicStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1957
|
|
|
|
|
1958
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1959
|
|
|
|
|
1960
|
|
|
$this->assertAttributeEquals('bar', 'publicStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1961
|
|
|
} |
|
1962
|
|
|
|
|
1963
|
|
|
public function testAssertPublicStaticAttributeNotEquals() |
|
1964
|
|
|
{ |
|
1965
|
|
|
$this->assertAttributeNotEquals('bar', 'publicStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1966
|
|
|
|
|
1967
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1968
|
|
|
|
|
1969
|
|
|
$this->assertAttributeNotEquals('foo', 'publicStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1970
|
|
|
} |
|
1971
|
|
|
|
|
1972
|
|
|
public function testAssertProtectedStaticAttributeEquals() |
|
1973
|
|
|
{ |
|
1974
|
|
|
$this->assertAttributeEquals('bar', 'protectedStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1975
|
|
|
|
|
1976
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1977
|
|
|
|
|
1978
|
|
|
$this->assertAttributeEquals('foo', 'protectedStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1979
|
|
|
} |
|
1980
|
|
|
|
|
1981
|
|
|
public function testAssertProtectedStaticAttributeNotEquals() |
|
1982
|
|
|
{ |
|
1983
|
|
|
$this->assertAttributeNotEquals('foo', 'protectedStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1984
|
|
|
|
|
1985
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1986
|
|
|
|
|
1987
|
|
|
$this->assertAttributeNotEquals('bar', 'protectedStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1988
|
|
|
} |
|
1989
|
|
|
|
|
1990
|
|
|
public function testAssertPrivateStaticAttributeEquals() |
|
1991
|
|
|
{ |
|
1992
|
|
|
$this->assertAttributeEquals('baz', 'privateStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1993
|
|
|
|
|
1994
|
|
|
$this->expectException(AssertionFailedError::class); |
|
1995
|
|
|
|
|
1996
|
|
|
$this->assertAttributeEquals('foo', 'privateStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
1997
|
|
|
} |
|
1998
|
|
|
|
|
1999
|
|
|
public function testAssertPrivateStaticAttributeNotEquals() |
|
2000
|
|
|
{ |
|
2001
|
|
|
$this->assertAttributeNotEquals('foo', 'privateStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
2002
|
|
|
|
|
2003
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2004
|
|
|
|
|
2005
|
|
|
$this->assertAttributeNotEquals('baz', 'privateStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
2006
|
|
|
} |
|
2007
|
|
|
|
|
2008
|
|
|
public function testAssertClassHasAttributeThrowsException() |
|
2009
|
|
|
{ |
|
2010
|
|
|
$this->expectException(Exception::class); |
|
2011
|
|
|
|
|
2012
|
|
|
$this->assertClassHasAttribute(null, null); |
|
2013
|
|
|
} |
|
2014
|
|
|
|
|
2015
|
|
|
public function testAssertClassHasAttributeThrowsException2() |
|
2016
|
|
|
{ |
|
2017
|
|
|
$this->expectException(Exception::class); |
|
2018
|
|
|
|
|
2019
|
|
|
$this->assertClassHasAttribute('foo', null); |
|
2020
|
|
|
} |
|
2021
|
|
|
|
|
2022
|
|
|
public function testAssertClassHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
|
2023
|
|
|
{ |
|
2024
|
|
|
$this->expectException(Exception::class); |
|
2025
|
|
|
|
|
2026
|
|
|
$this->assertClassHasAttribute('1', \ClassWithNonPublicAttributes::class); |
|
2027
|
|
|
} |
|
2028
|
|
|
|
|
2029
|
|
|
public function testAssertClassNotHasAttributeThrowsException() |
|
2030
|
|
|
{ |
|
2031
|
|
|
$this->expectException(Exception::class); |
|
2032
|
|
|
|
|
2033
|
|
|
$this->assertClassNotHasAttribute(null, null); |
|
2034
|
|
|
} |
|
2035
|
|
|
|
|
2036
|
|
|
public function testAssertClassNotHasAttributeThrowsException2() |
|
2037
|
|
|
{ |
|
2038
|
|
|
$this->expectException(Exception::class); |
|
2039
|
|
|
|
|
2040
|
|
|
$this->assertClassNotHasAttribute('foo', null); |
|
2041
|
|
|
} |
|
2042
|
|
|
|
|
2043
|
|
|
public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
|
2044
|
|
|
{ |
|
2045
|
|
|
$this->expectException(Exception::class); |
|
2046
|
|
|
|
|
2047
|
|
|
$this->assertClassNotHasAttribute('1', \ClassWithNonPublicAttributes::class); |
|
2048
|
|
|
} |
|
2049
|
|
|
|
|
2050
|
|
|
public function testAssertClassHasStaticAttributeThrowsException() |
|
2051
|
|
|
{ |
|
2052
|
|
|
$this->expectException(Exception::class); |
|
2053
|
|
|
|
|
2054
|
|
|
$this->assertClassHasStaticAttribute(null, null); |
|
2055
|
|
|
} |
|
2056
|
|
|
|
|
2057
|
|
|
public function testAssertClassHasStaticAttributeThrowsException2() |
|
2058
|
|
|
{ |
|
2059
|
|
|
$this->expectException(Exception::class); |
|
2060
|
|
|
|
|
2061
|
|
|
$this->assertClassHasStaticAttribute('foo', null); |
|
2062
|
|
|
} |
|
2063
|
|
|
|
|
2064
|
|
|
public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid() |
|
2065
|
|
|
{ |
|
2066
|
|
|
$this->expectException(Exception::class); |
|
2067
|
|
|
|
|
2068
|
|
|
$this->assertClassHasStaticAttribute('1', \ClassWithNonPublicAttributes::class); |
|
2069
|
|
|
} |
|
2070
|
|
|
|
|
2071
|
|
|
public function testAssertClassNotHasStaticAttributeThrowsException() |
|
2072
|
|
|
{ |
|
2073
|
|
|
$this->expectException(Exception::class); |
|
2074
|
|
|
|
|
2075
|
|
|
$this->assertClassNotHasStaticAttribute(null, null); |
|
2076
|
|
|
} |
|
2077
|
|
|
|
|
2078
|
|
|
public function testAssertClassNotHasStaticAttributeThrowsException2() |
|
2079
|
|
|
{ |
|
2080
|
|
|
$this->expectException(Exception::class); |
|
2081
|
|
|
|
|
2082
|
|
|
$this->assertClassNotHasStaticAttribute('foo', null); |
|
2083
|
|
|
} |
|
2084
|
|
|
|
|
2085
|
|
|
public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid() |
|
2086
|
|
|
{ |
|
2087
|
|
|
$this->expectException(Exception::class); |
|
2088
|
|
|
|
|
2089
|
|
|
$this->assertClassNotHasStaticAttribute('1', \ClassWithNonPublicAttributes::class); |
|
2090
|
|
|
} |
|
2091
|
|
|
|
|
2092
|
|
|
public function testAssertObjectHasAttributeThrowsException() |
|
2093
|
|
|
{ |
|
2094
|
|
|
$this->expectException(Exception::class); |
|
2095
|
|
|
|
|
2096
|
|
|
$this->assertObjectHasAttribute(null, null); |
|
|
|
|
|
|
2097
|
|
|
} |
|
2098
|
|
|
|
|
2099
|
|
|
public function testAssertObjectHasAttributeThrowsException2() |
|
2100
|
|
|
{ |
|
2101
|
|
|
$this->expectException(Exception::class); |
|
2102
|
|
|
|
|
2103
|
|
|
$this->assertObjectHasAttribute('foo', null); |
|
|
|
|
|
|
2104
|
|
|
} |
|
2105
|
|
|
|
|
2106
|
|
|
public function testAssertObjectHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
|
2107
|
|
|
{ |
|
2108
|
|
|
$this->expectException(Exception::class); |
|
2109
|
|
|
|
|
2110
|
|
|
$this->assertObjectHasAttribute('1', \ClassWithNonPublicAttributes::class); |
|
2111
|
|
|
} |
|
2112
|
|
|
|
|
2113
|
|
|
public function testAssertObjectNotHasAttributeThrowsException() |
|
2114
|
|
|
{ |
|
2115
|
|
|
$this->expectException(Exception::class); |
|
2116
|
|
|
|
|
2117
|
|
|
$this->assertObjectNotHasAttribute(null, null); |
|
|
|
|
|
|
2118
|
|
|
} |
|
2119
|
|
|
|
|
2120
|
|
|
public function testAssertObjectNotHasAttributeThrowsException2() |
|
2121
|
|
|
{ |
|
2122
|
|
|
$this->expectException(Exception::class); |
|
2123
|
|
|
|
|
2124
|
|
|
$this->assertObjectNotHasAttribute('foo', null); |
|
|
|
|
|
|
2125
|
|
|
} |
|
2126
|
|
|
|
|
2127
|
|
|
public function testAssertObjectNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
|
2128
|
|
|
{ |
|
2129
|
|
|
$this->expectException(Exception::class); |
|
2130
|
|
|
|
|
2131
|
|
|
$this->assertObjectNotHasAttribute('1', \ClassWithNonPublicAttributes::class); |
|
2132
|
|
|
} |
|
2133
|
|
|
|
|
2134
|
|
|
public function testClassHasPublicAttribute() |
|
2135
|
|
|
{ |
|
2136
|
|
|
$this->assertClassHasAttribute('publicAttribute', \ClassWithNonPublicAttributes::class); |
|
2137
|
|
|
|
|
2138
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2139
|
|
|
|
|
2140
|
|
|
$this->assertClassHasAttribute('attribute', \ClassWithNonPublicAttributes::class); |
|
2141
|
|
|
} |
|
2142
|
|
|
|
|
2143
|
|
|
public function testClassNotHasPublicAttribute() |
|
2144
|
|
|
{ |
|
2145
|
|
|
$this->assertClassNotHasAttribute('attribute', \ClassWithNonPublicAttributes::class); |
|
2146
|
|
|
|
|
2147
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2148
|
|
|
|
|
2149
|
|
|
$this->assertClassNotHasAttribute('publicAttribute', \ClassWithNonPublicAttributes::class); |
|
2150
|
|
|
} |
|
2151
|
|
|
|
|
2152
|
|
|
public function testClassHasPublicStaticAttribute() |
|
2153
|
|
|
{ |
|
2154
|
|
|
$this->assertClassHasStaticAttribute('publicStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
2155
|
|
|
|
|
2156
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2157
|
|
|
|
|
2158
|
|
|
$this->assertClassHasStaticAttribute('attribute', \ClassWithNonPublicAttributes::class); |
|
2159
|
|
|
} |
|
2160
|
|
|
|
|
2161
|
|
|
public function testClassNotHasPublicStaticAttribute() |
|
2162
|
|
|
{ |
|
2163
|
|
|
$this->assertClassNotHasStaticAttribute('attribute', \ClassWithNonPublicAttributes::class); |
|
2164
|
|
|
|
|
2165
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2166
|
|
|
|
|
2167
|
|
|
$this->assertClassNotHasStaticAttribute('publicStaticAttribute', \ClassWithNonPublicAttributes::class); |
|
2168
|
|
|
} |
|
2169
|
|
|
|
|
2170
|
|
|
public function testObjectHasPublicAttribute() |
|
2171
|
|
|
{ |
|
2172
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
2173
|
|
|
|
|
2174
|
|
|
$this->assertObjectHasAttribute('publicAttribute', $obj); |
|
2175
|
|
|
|
|
2176
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2177
|
|
|
|
|
2178
|
|
|
$this->assertObjectHasAttribute('attribute', $obj); |
|
2179
|
|
|
} |
|
2180
|
|
|
|
|
2181
|
|
|
public function testObjectNotHasPublicAttribute() |
|
2182
|
|
|
{ |
|
2183
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
2184
|
|
|
|
|
2185
|
|
|
$this->assertObjectNotHasAttribute('attribute', $obj); |
|
2186
|
|
|
|
|
2187
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2188
|
|
|
|
|
2189
|
|
|
$this->assertObjectNotHasAttribute('publicAttribute', $obj); |
|
2190
|
|
|
} |
|
2191
|
|
|
|
|
2192
|
|
|
public function testObjectHasOnTheFlyAttribute() |
|
2193
|
|
|
{ |
|
2194
|
|
|
$obj = new \stdClass; |
|
2195
|
|
|
$obj->foo = 'bar'; |
|
2196
|
|
|
|
|
2197
|
|
|
$this->assertObjectHasAttribute('foo', $obj); |
|
2198
|
|
|
|
|
2199
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2200
|
|
|
|
|
2201
|
|
|
$this->assertObjectHasAttribute('bar', $obj); |
|
2202
|
|
|
} |
|
2203
|
|
|
|
|
2204
|
|
|
public function testObjectNotHasOnTheFlyAttribute() |
|
2205
|
|
|
{ |
|
2206
|
|
|
$obj = new \stdClass; |
|
2207
|
|
|
$obj->foo = 'bar'; |
|
2208
|
|
|
|
|
2209
|
|
|
$this->assertObjectNotHasAttribute('bar', $obj); |
|
2210
|
|
|
|
|
2211
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2212
|
|
|
|
|
2213
|
|
|
$this->assertObjectNotHasAttribute('foo', $obj); |
|
2214
|
|
|
} |
|
2215
|
|
|
|
|
2216
|
|
|
public function testObjectHasProtectedAttribute() |
|
2217
|
|
|
{ |
|
2218
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
2219
|
|
|
|
|
2220
|
|
|
$this->assertObjectHasAttribute('protectedAttribute', $obj); |
|
2221
|
|
|
|
|
2222
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2223
|
|
|
|
|
2224
|
|
|
$this->assertObjectHasAttribute('attribute', $obj); |
|
2225
|
|
|
} |
|
2226
|
|
|
|
|
2227
|
|
|
public function testObjectNotHasProtectedAttribute() |
|
2228
|
|
|
{ |
|
2229
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
2230
|
|
|
|
|
2231
|
|
|
$this->assertObjectNotHasAttribute('attribute', $obj); |
|
2232
|
|
|
|
|
2233
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2234
|
|
|
|
|
2235
|
|
|
$this->assertObjectNotHasAttribute('protectedAttribute', $obj); |
|
2236
|
|
|
} |
|
2237
|
|
|
|
|
2238
|
|
|
public function testObjectHasPrivateAttribute() |
|
2239
|
|
|
{ |
|
2240
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
2241
|
|
|
|
|
2242
|
|
|
$this->assertObjectHasAttribute('privateAttribute', $obj); |
|
2243
|
|
|
|
|
2244
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2245
|
|
|
|
|
2246
|
|
|
$this->assertObjectHasAttribute('attribute', $obj); |
|
2247
|
|
|
} |
|
2248
|
|
|
|
|
2249
|
|
|
public function testObjectNotHasPrivateAttribute() |
|
2250
|
|
|
{ |
|
2251
|
|
|
$obj = new \ClassWithNonPublicAttributes; |
|
2252
|
|
|
|
|
2253
|
|
|
$this->assertObjectNotHasAttribute('attribute', $obj); |
|
2254
|
|
|
|
|
2255
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2256
|
|
|
|
|
2257
|
|
|
$this->assertObjectNotHasAttribute('privateAttribute', $obj); |
|
2258
|
|
|
} |
|
2259
|
|
|
|
|
2260
|
|
|
public function testAssertThatAttributeEquals() |
|
2261
|
|
|
{ |
|
2262
|
|
|
$this->assertThat( |
|
2263
|
|
|
new \ClassWithNonPublicAttributes, |
|
2264
|
|
|
$this->attribute( |
|
2265
|
|
|
$this->equalTo('foo'), |
|
2266
|
|
|
'publicAttribute' |
|
2267
|
|
|
) |
|
2268
|
|
|
); |
|
2269
|
|
|
} |
|
2270
|
|
|
|
|
2271
|
|
|
public function testAssertThatAttributeEquals2() |
|
2272
|
|
|
{ |
|
2273
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2274
|
|
|
|
|
2275
|
|
|
$this->assertThat( |
|
2276
|
|
|
new \ClassWithNonPublicAttributes, |
|
2277
|
|
|
$this->attribute( |
|
2278
|
|
|
$this->equalTo('bar'), |
|
2279
|
|
|
'publicAttribute' |
|
2280
|
|
|
) |
|
2281
|
|
|
); |
|
2282
|
|
|
} |
|
2283
|
|
|
|
|
2284
|
|
|
public function testAssertThatAttributeEqualTo() |
|
2285
|
|
|
{ |
|
2286
|
|
|
$this->assertThat( |
|
2287
|
|
|
new \ClassWithNonPublicAttributes, |
|
2288
|
|
|
$this->attributeEqualTo('publicAttribute', 'foo') |
|
2289
|
|
|
); |
|
2290
|
|
|
} |
|
2291
|
|
|
|
|
2292
|
|
|
/** |
|
2293
|
|
|
* @doesNotPerformAssertions |
|
2294
|
|
|
*/ |
|
2295
|
|
|
public function testAssertThatAnything() |
|
2296
|
|
|
{ |
|
2297
|
|
|
$this->assertThat('anything', $this->anything()); |
|
2298
|
|
|
} |
|
2299
|
|
|
|
|
2300
|
|
|
public function testAssertThatIsTrue() |
|
2301
|
|
|
{ |
|
2302
|
|
|
$this->assertThat(true, $this->isTrue()); |
|
2303
|
|
|
} |
|
2304
|
|
|
|
|
2305
|
|
|
public function testAssertThatIsFalse() |
|
2306
|
|
|
{ |
|
2307
|
|
|
$this->assertThat(false, $this->isFalse()); |
|
2308
|
|
|
} |
|
2309
|
|
|
|
|
2310
|
|
|
public function testAssertThatIsJson() |
|
2311
|
|
|
{ |
|
2312
|
|
|
$this->assertThat('{}', $this->isJson()); |
|
2313
|
|
|
} |
|
2314
|
|
|
|
|
2315
|
|
|
/** |
|
2316
|
|
|
* @doesNotPerformAssertions |
|
2317
|
|
|
*/ |
|
2318
|
|
|
public function testAssertThatAnythingAndAnything() |
|
2319
|
|
|
{ |
|
2320
|
|
|
$this->assertThat( |
|
2321
|
|
|
'anything', |
|
2322
|
|
|
$this->logicalAnd( |
|
2323
|
|
|
$this->anything(), |
|
2324
|
|
|
$this->anything() |
|
2325
|
|
|
) |
|
2326
|
|
|
); |
|
2327
|
|
|
} |
|
2328
|
|
|
|
|
2329
|
|
|
/** |
|
2330
|
|
|
* @doesNotPerformAssertions |
|
2331
|
|
|
*/ |
|
2332
|
|
|
public function testAssertThatAnythingOrAnything() |
|
2333
|
|
|
{ |
|
2334
|
|
|
$this->assertThat( |
|
2335
|
|
|
'anything', |
|
2336
|
|
|
$this->logicalOr( |
|
2337
|
|
|
$this->anything(), |
|
2338
|
|
|
$this->anything() |
|
2339
|
|
|
) |
|
2340
|
|
|
); |
|
2341
|
|
|
} |
|
2342
|
|
|
|
|
2343
|
|
|
/** |
|
2344
|
|
|
* @doesNotPerformAssertions |
|
2345
|
|
|
*/ |
|
2346
|
|
|
public function testAssertThatAnythingXorNotAnything() |
|
2347
|
|
|
{ |
|
2348
|
|
|
$this->assertThat( |
|
2349
|
|
|
'anything', |
|
2350
|
|
|
$this->logicalXor( |
|
2351
|
|
|
$this->anything(), |
|
2352
|
|
|
$this->logicalNot($this->anything()) |
|
2353
|
|
|
) |
|
2354
|
|
|
); |
|
2355
|
|
|
} |
|
2356
|
|
|
|
|
2357
|
|
|
public function testAssertThatContains() |
|
2358
|
|
|
{ |
|
2359
|
|
|
$this->assertThat(['foo'], $this->contains('foo')); |
|
2360
|
|
|
} |
|
2361
|
|
|
|
|
2362
|
|
|
public function testAssertThatStringContains() |
|
2363
|
|
|
{ |
|
2364
|
|
|
$this->assertThat('barfoobar', $this->stringContains('foo')); |
|
2365
|
|
|
} |
|
2366
|
|
|
|
|
2367
|
|
|
public function testAssertThatContainsOnly() |
|
2368
|
|
|
{ |
|
2369
|
|
|
$this->assertThat(['foo'], $this->containsOnly('string')); |
|
2370
|
|
|
} |
|
2371
|
|
|
|
|
2372
|
|
|
public function testAssertThatContainsOnlyInstancesOf() |
|
2373
|
|
|
{ |
|
2374
|
|
|
$this->assertThat([new \Book], $this->containsOnlyInstancesOf(\Book::class)); |
|
2375
|
|
|
} |
|
2376
|
|
|
|
|
2377
|
|
|
public function testAssertThatArrayHasKey() |
|
2378
|
|
|
{ |
|
2379
|
|
|
$this->assertThat(['foo' => 'bar'], $this->arrayHasKey('foo')); |
|
2380
|
|
|
} |
|
2381
|
|
|
|
|
2382
|
|
|
public function testAssertThatClassHasAttribute() |
|
2383
|
|
|
{ |
|
2384
|
|
|
$this->assertThat( |
|
2385
|
|
|
new \ClassWithNonPublicAttributes, |
|
2386
|
|
|
$this->classHasAttribute('publicAttribute') |
|
2387
|
|
|
); |
|
2388
|
|
|
} |
|
2389
|
|
|
|
|
2390
|
|
|
public function testAssertThatClassHasStaticAttribute() |
|
2391
|
|
|
{ |
|
2392
|
|
|
$this->assertThat( |
|
2393
|
|
|
new \ClassWithNonPublicAttributes, |
|
2394
|
|
|
$this->classHasStaticAttribute('publicStaticAttribute') |
|
2395
|
|
|
); |
|
2396
|
|
|
} |
|
2397
|
|
|
|
|
2398
|
|
|
public function testAssertThatObjectHasAttribute() |
|
2399
|
|
|
{ |
|
2400
|
|
|
$this->assertThat( |
|
2401
|
|
|
new \ClassWithNonPublicAttributes, |
|
2402
|
|
|
$this->objectHasAttribute('publicAttribute') |
|
2403
|
|
|
); |
|
2404
|
|
|
} |
|
2405
|
|
|
|
|
2406
|
|
|
public function testAssertThatEqualTo() |
|
2407
|
|
|
{ |
|
2408
|
|
|
$this->assertThat('foo', $this->equalTo('foo')); |
|
2409
|
|
|
} |
|
2410
|
|
|
|
|
2411
|
|
|
public function testAssertThatIdenticalTo() |
|
2412
|
|
|
{ |
|
2413
|
|
|
$value = new \stdClass; |
|
2414
|
|
|
$constraint = $this->identicalTo($value); |
|
2415
|
|
|
|
|
2416
|
|
|
$this->assertThat($value, $constraint); |
|
2417
|
|
|
} |
|
2418
|
|
|
|
|
2419
|
|
|
public function testAssertThatIsInstanceOf() |
|
2420
|
|
|
{ |
|
2421
|
|
|
$this->assertThat(new \stdClass, $this->isInstanceOf('StdClass')); |
|
2422
|
|
|
} |
|
2423
|
|
|
|
|
2424
|
|
|
public function testAssertThatIsType() |
|
2425
|
|
|
{ |
|
2426
|
|
|
$this->assertThat('string', $this->isType('string')); |
|
2427
|
|
|
} |
|
2428
|
|
|
|
|
2429
|
|
|
public function testAssertThatIsEmpty() |
|
2430
|
|
|
{ |
|
2431
|
|
|
$this->assertThat([], $this->isEmpty()); |
|
2432
|
|
|
} |
|
2433
|
|
|
|
|
2434
|
|
|
public function testAssertThatFileExists() |
|
2435
|
|
|
{ |
|
2436
|
|
|
$this->assertThat(__FILE__, $this->fileExists()); |
|
2437
|
|
|
} |
|
2438
|
|
|
|
|
2439
|
|
|
public function testAssertThatGreaterThan() |
|
2440
|
|
|
{ |
|
2441
|
|
|
$this->assertThat(2, $this->greaterThan(1)); |
|
2442
|
|
|
} |
|
2443
|
|
|
|
|
2444
|
|
|
public function testAssertThatGreaterThanOrEqual() |
|
2445
|
|
|
{ |
|
2446
|
|
|
$this->assertThat(2, $this->greaterThanOrEqual(1)); |
|
2447
|
|
|
} |
|
2448
|
|
|
|
|
2449
|
|
|
public function testAssertThatLessThan() |
|
2450
|
|
|
{ |
|
2451
|
|
|
$this->assertThat(1, $this->lessThan(2)); |
|
2452
|
|
|
} |
|
2453
|
|
|
|
|
2454
|
|
|
public function testAssertThatLessThanOrEqual() |
|
2455
|
|
|
{ |
|
2456
|
|
|
$this->assertThat(1, $this->lessThanOrEqual(2)); |
|
2457
|
|
|
} |
|
2458
|
|
|
|
|
2459
|
|
|
public function testAssertThatMatchesRegularExpression() |
|
2460
|
|
|
{ |
|
2461
|
|
|
$this->assertThat('foobar', $this->matchesRegularExpression('/foo/')); |
|
2462
|
|
|
} |
|
2463
|
|
|
|
|
2464
|
|
|
public function testAssertThatCallback() |
|
2465
|
|
|
{ |
|
2466
|
|
|
$this->assertThat( |
|
2467
|
|
|
null, |
|
2468
|
|
|
$this->callback(function ($other) { |
|
|
|
|
|
|
2469
|
|
|
return true; |
|
2470
|
|
|
}) |
|
2471
|
|
|
); |
|
2472
|
|
|
} |
|
2473
|
|
|
|
|
2474
|
|
|
public function testAssertThatCountOf() |
|
2475
|
|
|
{ |
|
2476
|
|
|
$this->assertThat([1], $this->countOf(1)); |
|
2477
|
|
|
} |
|
2478
|
|
|
|
|
2479
|
|
|
public function testAssertFileEquals() |
|
2480
|
|
|
{ |
|
2481
|
|
|
$this->assertFileEquals( |
|
2482
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2483
|
|
|
$this->filesDirectory . 'foo.xml' |
|
2484
|
|
|
); |
|
2485
|
|
|
|
|
2486
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2487
|
|
|
|
|
2488
|
|
|
$this->assertFileEquals( |
|
2489
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2490
|
|
|
$this->filesDirectory . 'bar.xml' |
|
2491
|
|
|
); |
|
2492
|
|
|
} |
|
2493
|
|
|
|
|
2494
|
|
|
public function testAssertFileNotEquals() |
|
2495
|
|
|
{ |
|
2496
|
|
|
$this->assertFileNotEquals( |
|
2497
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2498
|
|
|
$this->filesDirectory . 'bar.xml' |
|
2499
|
|
|
); |
|
2500
|
|
|
|
|
2501
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2502
|
|
|
|
|
2503
|
|
|
$this->assertFileNotEquals( |
|
2504
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2505
|
|
|
$this->filesDirectory . 'foo.xml' |
|
2506
|
|
|
); |
|
2507
|
|
|
} |
|
2508
|
|
|
|
|
2509
|
|
|
public function testAssertStringEqualsFile() |
|
2510
|
|
|
{ |
|
2511
|
|
|
$this->assertStringEqualsFile( |
|
2512
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2513
|
|
|
\file_get_contents($this->filesDirectory . 'foo.xml') |
|
2514
|
|
|
); |
|
2515
|
|
|
|
|
2516
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2517
|
|
|
|
|
2518
|
|
|
$this->assertStringEqualsFile( |
|
2519
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2520
|
|
|
\file_get_contents($this->filesDirectory . 'bar.xml') |
|
2521
|
|
|
); |
|
2522
|
|
|
} |
|
2523
|
|
|
|
|
2524
|
|
|
public function testAssertStringNotEqualsFile() |
|
2525
|
|
|
{ |
|
2526
|
|
|
$this->assertStringNotEqualsFile( |
|
2527
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2528
|
|
|
\file_get_contents($this->filesDirectory . 'bar.xml') |
|
2529
|
|
|
); |
|
2530
|
|
|
|
|
2531
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2532
|
|
|
|
|
2533
|
|
|
$this->assertStringNotEqualsFile( |
|
2534
|
|
|
$this->filesDirectory . 'foo.xml', |
|
2535
|
|
|
\file_get_contents($this->filesDirectory . 'foo.xml') |
|
2536
|
|
|
); |
|
2537
|
|
|
} |
|
2538
|
|
|
|
|
2539
|
|
|
public function testAssertStringStartsWithThrowsException() |
|
2540
|
|
|
{ |
|
2541
|
|
|
$this->expectException(Exception::class); |
|
2542
|
|
|
|
|
2543
|
|
|
$this->assertStringStartsWith(null, null); |
|
2544
|
|
|
} |
|
2545
|
|
|
|
|
2546
|
|
|
public function testAssertStringStartsWithThrowsException2() |
|
2547
|
|
|
{ |
|
2548
|
|
|
$this->expectException(Exception::class); |
|
2549
|
|
|
|
|
2550
|
|
|
$this->assertStringStartsWith('', null); |
|
2551
|
|
|
} |
|
2552
|
|
|
|
|
2553
|
|
|
public function testAssertStringStartsNotWithThrowsException() |
|
2554
|
|
|
{ |
|
2555
|
|
|
$this->expectException(Exception::class); |
|
2556
|
|
|
|
|
2557
|
|
|
$this->assertStringStartsNotWith(null, null); |
|
2558
|
|
|
} |
|
2559
|
|
|
|
|
2560
|
|
|
public function testAssertStringStartsNotWithThrowsException2() |
|
2561
|
|
|
{ |
|
2562
|
|
|
$this->expectException(Exception::class); |
|
2563
|
|
|
|
|
2564
|
|
|
$this->assertStringStartsNotWith('', null); |
|
2565
|
|
|
} |
|
2566
|
|
|
|
|
2567
|
|
|
public function testAssertStringEndsWithThrowsException() |
|
2568
|
|
|
{ |
|
2569
|
|
|
$this->expectException(Exception::class); |
|
2570
|
|
|
|
|
2571
|
|
|
$this->assertStringEndsWith(null, null); |
|
2572
|
|
|
} |
|
2573
|
|
|
|
|
2574
|
|
|
public function testAssertStringEndsWithThrowsException2() |
|
2575
|
|
|
{ |
|
2576
|
|
|
$this->expectException(Exception::class); |
|
2577
|
|
|
|
|
2578
|
|
|
$this->assertStringEndsWith('', null); |
|
2579
|
|
|
} |
|
2580
|
|
|
|
|
2581
|
|
|
public function testAssertStringEndsNotWithThrowsException() |
|
2582
|
|
|
{ |
|
2583
|
|
|
$this->expectException(Exception::class); |
|
2584
|
|
|
|
|
2585
|
|
|
$this->assertStringEndsNotWith(null, null); |
|
2586
|
|
|
} |
|
2587
|
|
|
|
|
2588
|
|
|
public function testAssertStringEndsNotWithThrowsException2() |
|
2589
|
|
|
{ |
|
2590
|
|
|
$this->expectException(Exception::class); |
|
2591
|
|
|
|
|
2592
|
|
|
$this->assertStringEndsNotWith('', null); |
|
2593
|
|
|
} |
|
2594
|
|
|
|
|
2595
|
|
|
public function testAssertStringStartsWith() |
|
2596
|
|
|
{ |
|
2597
|
|
|
$this->assertStringStartsWith('prefix', 'prefixfoo'); |
|
2598
|
|
|
|
|
2599
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2600
|
|
|
|
|
2601
|
|
|
$this->assertStringStartsWith('prefix', 'foo'); |
|
2602
|
|
|
} |
|
2603
|
|
|
|
|
2604
|
|
|
public function testAssertStringStartsNotWith() |
|
2605
|
|
|
{ |
|
2606
|
|
|
$this->assertStringStartsNotWith('prefix', 'foo'); |
|
2607
|
|
|
|
|
2608
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2609
|
|
|
|
|
2610
|
|
|
$this->assertStringStartsNotWith('prefix', 'prefixfoo'); |
|
2611
|
|
|
} |
|
2612
|
|
|
|
|
2613
|
|
|
public function testAssertStringEndsWith() |
|
2614
|
|
|
{ |
|
2615
|
|
|
$this->assertStringEndsWith('suffix', 'foosuffix'); |
|
2616
|
|
|
|
|
2617
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2618
|
|
|
|
|
2619
|
|
|
$this->assertStringEndsWith('suffix', 'foo'); |
|
2620
|
|
|
} |
|
2621
|
|
|
|
|
2622
|
|
|
public function testAssertStringEndsNotWith() |
|
2623
|
|
|
{ |
|
2624
|
|
|
$this->assertStringEndsNotWith('suffix', 'foo'); |
|
2625
|
|
|
|
|
2626
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2627
|
|
|
|
|
2628
|
|
|
$this->assertStringEndsNotWith('suffix', 'foosuffix'); |
|
2629
|
|
|
} |
|
2630
|
|
|
|
|
2631
|
|
|
public function testAssertStringMatchesFormatRaisesExceptionForInvalidFirstArgument() |
|
2632
|
|
|
{ |
|
2633
|
|
|
$this->expectException(Exception::class); |
|
2634
|
|
|
|
|
2635
|
|
|
$this->assertStringMatchesFormat(null, ''); |
|
2636
|
|
|
} |
|
2637
|
|
|
|
|
2638
|
|
|
public function testAssertStringMatchesFormatRaisesExceptionForInvalidSecondArgument() |
|
2639
|
|
|
{ |
|
2640
|
|
|
$this->expectException(Exception::class); |
|
2641
|
|
|
|
|
2642
|
|
|
$this->assertStringMatchesFormat('', null); |
|
2643
|
|
|
} |
|
2644
|
|
|
|
|
2645
|
|
|
public function testAssertStringMatchesFormat() |
|
2646
|
|
|
{ |
|
2647
|
|
|
$this->assertStringMatchesFormat('*%s*', '***'); |
|
2648
|
|
|
} |
|
2649
|
|
|
|
|
2650
|
|
|
public function testAssertStringMatchesFormatFailure() |
|
2651
|
|
|
{ |
|
2652
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2653
|
|
|
|
|
2654
|
|
|
$this->assertStringMatchesFormat('*%s*', '**'); |
|
2655
|
|
|
} |
|
2656
|
|
|
|
|
2657
|
|
|
public function testAssertStringNotMatchesFormatRaisesExceptionForInvalidFirstArgument() |
|
2658
|
|
|
{ |
|
2659
|
|
|
$this->expectException(Exception::class); |
|
2660
|
|
|
|
|
2661
|
|
|
$this->assertStringNotMatchesFormat(null, ''); |
|
2662
|
|
|
} |
|
2663
|
|
|
|
|
2664
|
|
|
public function testAssertStringNotMatchesFormatRaisesExceptionForInvalidSecondArgument() |
|
2665
|
|
|
{ |
|
2666
|
|
|
$this->expectException(Exception::class); |
|
2667
|
|
|
|
|
2668
|
|
|
$this->assertStringNotMatchesFormat('', null); |
|
2669
|
|
|
} |
|
2670
|
|
|
|
|
2671
|
|
|
public function testAssertStringNotMatchesFormat() |
|
2672
|
|
|
{ |
|
2673
|
|
|
$this->assertStringNotMatchesFormat('*%s*', '**'); |
|
2674
|
|
|
|
|
2675
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2676
|
|
|
|
|
2677
|
|
|
$this->assertStringMatchesFormat('*%s*', '**'); |
|
2678
|
|
|
} |
|
2679
|
|
|
|
|
2680
|
|
|
public function testAssertEmpty() |
|
2681
|
|
|
{ |
|
2682
|
|
|
$this->assertEmpty([]); |
|
2683
|
|
|
|
|
2684
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2685
|
|
|
|
|
2686
|
|
|
$this->assertEmpty(['foo']); |
|
2687
|
|
|
} |
|
2688
|
|
|
|
|
2689
|
|
|
public function testAssertNotEmpty() |
|
2690
|
|
|
{ |
|
2691
|
|
|
$this->assertNotEmpty(['foo']); |
|
2692
|
|
|
|
|
2693
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2694
|
|
|
|
|
2695
|
|
|
$this->assertNotEmpty([]); |
|
2696
|
|
|
} |
|
2697
|
|
|
|
|
2698
|
|
|
public function testAssertAttributeEmpty() |
|
2699
|
|
|
{ |
|
2700
|
|
|
$o = new \stdClass; |
|
2701
|
|
|
$o->a = []; |
|
2702
|
|
|
|
|
2703
|
|
|
$this->assertAttributeEmpty('a', $o); |
|
2704
|
|
|
|
|
2705
|
|
|
$o->a = ['b']; |
|
2706
|
|
|
|
|
2707
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2708
|
|
|
|
|
2709
|
|
|
$this->assertAttributeEmpty('a', $o); |
|
2710
|
|
|
} |
|
2711
|
|
|
|
|
2712
|
|
|
public function testAssertAttributeNotEmpty() |
|
2713
|
|
|
{ |
|
2714
|
|
|
$o = new \stdClass; |
|
2715
|
|
|
$o->a = ['b']; |
|
2716
|
|
|
|
|
2717
|
|
|
$this->assertAttributeNotEmpty('a', $o); |
|
2718
|
|
|
|
|
2719
|
|
|
$o->a = []; |
|
2720
|
|
|
|
|
2721
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2722
|
|
|
|
|
2723
|
|
|
$this->assertAttributeNotEmpty('a', $o); |
|
2724
|
|
|
} |
|
2725
|
|
|
|
|
2726
|
|
|
public function testMarkTestIncomplete() |
|
2727
|
|
|
{ |
|
2728
|
|
|
try { |
|
2729
|
|
|
$this->markTestIncomplete('incomplete'); |
|
2730
|
|
|
} catch (IncompleteTestError $e) { |
|
2731
|
|
|
$this->assertEquals('incomplete', $e->getMessage()); |
|
2732
|
|
|
|
|
2733
|
|
|
return; |
|
2734
|
|
|
} |
|
2735
|
|
|
|
|
2736
|
|
|
$this->fail(); |
|
2737
|
|
|
} |
|
2738
|
|
|
|
|
2739
|
|
|
public function testMarkTestSkipped() |
|
2740
|
|
|
{ |
|
2741
|
|
|
try { |
|
2742
|
|
|
$this->markTestSkipped('skipped'); |
|
2743
|
|
|
} catch (SkippedTestError $e) { |
|
2744
|
|
|
$this->assertEquals('skipped', $e->getMessage()); |
|
2745
|
|
|
|
|
2746
|
|
|
return; |
|
2747
|
|
|
} |
|
2748
|
|
|
|
|
2749
|
|
|
$this->fail(); |
|
2750
|
|
|
} |
|
2751
|
|
|
|
|
2752
|
|
|
public function testAssertCount() |
|
2753
|
|
|
{ |
|
2754
|
|
|
$this->assertCount(2, [1, 2]); |
|
2755
|
|
|
|
|
2756
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2757
|
|
|
|
|
2758
|
|
|
$this->assertCount(2, [1, 2, 3]); |
|
2759
|
|
|
} |
|
2760
|
|
|
|
|
2761
|
|
|
public function testAssertCountTraversable() |
|
2762
|
|
|
{ |
|
2763
|
|
|
$this->assertCount(2, new \ArrayIterator([1, 2])); |
|
2764
|
|
|
|
|
2765
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2766
|
|
|
|
|
2767
|
|
|
$this->assertCount(2, new \ArrayIterator([1, 2, 3])); |
|
2768
|
|
|
} |
|
2769
|
|
|
|
|
2770
|
|
|
public function testAssertCountThrowsExceptionIfExpectedCountIsNoInteger() |
|
2771
|
|
|
{ |
|
2772
|
|
|
try { |
|
2773
|
|
|
$this->assertCount('a', []); |
|
2774
|
|
|
} catch (Exception $e) { |
|
2775
|
|
|
$this->assertEquals('Argument #1 (No Value) of PHPUnit\Framework\Assert::assertCount() must be a integer', $e->getMessage()); |
|
2776
|
|
|
|
|
2777
|
|
|
return; |
|
2778
|
|
|
} |
|
2779
|
|
|
|
|
2780
|
|
|
$this->fail(); |
|
2781
|
|
|
} |
|
2782
|
|
|
|
|
2783
|
|
|
public function testAssertCountThrowsExceptionIfElementIsNotCountable() |
|
2784
|
|
|
{ |
|
2785
|
|
|
try { |
|
2786
|
|
|
$this->assertCount(2, ''); |
|
2787
|
|
|
} catch (Exception $e) { |
|
2788
|
|
|
$this->assertEquals('Argument #2 (No Value) of PHPUnit\Framework\Assert::assertCount() must be a countable or traversable', $e->getMessage()); |
|
2789
|
|
|
|
|
2790
|
|
|
return; |
|
2791
|
|
|
} |
|
2792
|
|
|
|
|
2793
|
|
|
$this->fail(); |
|
2794
|
|
|
} |
|
2795
|
|
|
|
|
2796
|
|
|
public function testAssertAttributeCount() |
|
2797
|
|
|
{ |
|
2798
|
|
|
$o = new \stdClass; |
|
2799
|
|
|
$o->a = []; |
|
2800
|
|
|
|
|
2801
|
|
|
$this->assertAttributeCount(0, 'a', $o); |
|
2802
|
|
|
} |
|
2803
|
|
|
|
|
2804
|
|
|
public function testAssertNotCount() |
|
2805
|
|
|
{ |
|
2806
|
|
|
$this->assertNotCount(2, [1, 2, 3]); |
|
2807
|
|
|
|
|
2808
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2809
|
|
|
|
|
2810
|
|
|
$this->assertNotCount(2, [1, 2]); |
|
2811
|
|
|
} |
|
2812
|
|
|
|
|
2813
|
|
|
public function testAssertNotCountThrowsExceptionIfExpectedCountIsNoInteger() |
|
2814
|
|
|
{ |
|
2815
|
|
|
$this->expectException(Exception::class); |
|
2816
|
|
|
|
|
2817
|
|
|
$this->assertNotCount('a', []); |
|
2818
|
|
|
} |
|
2819
|
|
|
|
|
2820
|
|
|
public function testAssertNotCountThrowsExceptionIfElementIsNotCountable() |
|
2821
|
|
|
{ |
|
2822
|
|
|
$this->expectException(Exception::class); |
|
2823
|
|
|
|
|
2824
|
|
|
$this->assertNotCount(2, ''); |
|
2825
|
|
|
} |
|
2826
|
|
|
|
|
2827
|
|
|
public function testAssertAttributeNotCount() |
|
2828
|
|
|
{ |
|
2829
|
|
|
$o = new \stdClass; |
|
2830
|
|
|
$o->a = []; |
|
2831
|
|
|
|
|
2832
|
|
|
$this->assertAttributeNotCount(1, 'a', $o); |
|
2833
|
|
|
} |
|
2834
|
|
|
|
|
2835
|
|
|
public function testAssertSameSize() |
|
2836
|
|
|
{ |
|
2837
|
|
|
$this->assertSameSize([1, 2], [3, 4]); |
|
2838
|
|
|
|
|
2839
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2840
|
|
|
|
|
2841
|
|
|
$this->assertSameSize([1, 2], [1, 2, 3]); |
|
2842
|
|
|
} |
|
2843
|
|
|
|
|
2844
|
|
|
public function testAssertSameSizeThrowsExceptionIfExpectedIsNotCountable() |
|
2845
|
|
|
{ |
|
2846
|
|
|
try { |
|
2847
|
|
|
$this->assertSameSize('a', []); |
|
|
|
|
|
|
2848
|
|
|
} catch (Exception $e) { |
|
2849
|
|
|
$this->assertEquals('Argument #1 (No Value) of PHPUnit\Framework\Assert::assertSameSize() must be a countable or traversable', $e->getMessage()); |
|
2850
|
|
|
|
|
2851
|
|
|
return; |
|
2852
|
|
|
} |
|
2853
|
|
|
|
|
2854
|
|
|
$this->fail(); |
|
2855
|
|
|
} |
|
2856
|
|
|
|
|
2857
|
|
|
public function testAssertSameSizeThrowsExceptionIfActualIsNotCountable() |
|
2858
|
|
|
{ |
|
2859
|
|
|
try { |
|
2860
|
|
|
$this->assertSameSize([], ''); |
|
|
|
|
|
|
2861
|
|
|
} catch (Exception $e) { |
|
2862
|
|
|
$this->assertEquals('Argument #2 (No Value) of PHPUnit\Framework\Assert::assertSameSize() must be a countable or traversable', $e->getMessage()); |
|
2863
|
|
|
|
|
2864
|
|
|
return; |
|
2865
|
|
|
} |
|
2866
|
|
|
|
|
2867
|
|
|
$this->fail(); |
|
2868
|
|
|
} |
|
2869
|
|
|
|
|
2870
|
|
|
public function testAssertNotSameSize() |
|
2871
|
|
|
{ |
|
2872
|
|
|
$this->assertNotSameSize([1, 2], [1, 2, 3]); |
|
2873
|
|
|
|
|
2874
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2875
|
|
|
|
|
2876
|
|
|
$this->assertNotSameSize([1, 2], [3, 4]); |
|
2877
|
|
|
} |
|
2878
|
|
|
|
|
2879
|
|
|
public function testAssertNotSameSizeThrowsExceptionIfExpectedIsNotCountable() |
|
2880
|
|
|
{ |
|
2881
|
|
|
$this->expectException(Exception::class); |
|
2882
|
|
|
|
|
2883
|
|
|
$this->assertNotSameSize('a', []); |
|
|
|
|
|
|
2884
|
|
|
} |
|
2885
|
|
|
|
|
2886
|
|
|
public function testAssertNotSameSizeThrowsExceptionIfActualIsNotCountable() |
|
2887
|
|
|
{ |
|
2888
|
|
|
$this->expectException(Exception::class); |
|
2889
|
|
|
|
|
2890
|
|
|
$this->assertNotSameSize([], ''); |
|
|
|
|
|
|
2891
|
|
|
} |
|
2892
|
|
|
|
|
2893
|
|
|
public function testAssertJsonRaisesExceptionForInvalidArgument() |
|
2894
|
|
|
{ |
|
2895
|
|
|
$this->expectException(Exception::class); |
|
2896
|
|
|
|
|
2897
|
|
|
$this->assertJson(null); |
|
2898
|
|
|
} |
|
2899
|
|
|
|
|
2900
|
|
|
public function testAssertJson() |
|
2901
|
|
|
{ |
|
2902
|
|
|
$this->assertJson('{}'); |
|
2903
|
|
|
} |
|
2904
|
|
|
|
|
2905
|
|
|
public function testAssertJsonStringEqualsJsonString() |
|
2906
|
|
|
{ |
|
2907
|
|
|
$expected = '{"Mascott" : "Tux"}'; |
|
2908
|
|
|
$actual = '{"Mascott" : "Tux"}'; |
|
2909
|
|
|
$message = 'Given Json strings do not match'; |
|
2910
|
|
|
|
|
2911
|
|
|
$this->assertJsonStringEqualsJsonString($expected, $actual, $message); |
|
2912
|
|
|
} |
|
2913
|
|
|
|
|
2914
|
|
|
/** |
|
2915
|
|
|
* @dataProvider validInvalidJsonDataprovider |
|
2916
|
|
|
*/ |
|
2917
|
|
|
public function testAssertJsonStringEqualsJsonStringErrorRaised($expected, $actual) |
|
2918
|
|
|
{ |
|
2919
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2920
|
|
|
|
|
2921
|
|
|
$this->assertJsonStringEqualsJsonString($expected, $actual); |
|
2922
|
|
|
} |
|
2923
|
|
|
|
|
2924
|
|
|
public function testAssertJsonStringNotEqualsJsonString() |
|
2925
|
|
|
{ |
|
2926
|
|
|
$expected = '{"Mascott" : "Beastie"}'; |
|
2927
|
|
|
$actual = '{"Mascott" : "Tux"}'; |
|
2928
|
|
|
$message = 'Given Json strings do match'; |
|
2929
|
|
|
|
|
2930
|
|
|
$this->assertJsonStringNotEqualsJsonString($expected, $actual, $message); |
|
2931
|
|
|
} |
|
2932
|
|
|
|
|
2933
|
|
|
/** |
|
2934
|
|
|
* @dataProvider validInvalidJsonDataprovider |
|
2935
|
|
|
*/ |
|
2936
|
|
|
public function testAssertJsonStringNotEqualsJsonStringErrorRaised($expected, $actual) |
|
2937
|
|
|
{ |
|
2938
|
|
|
$this->expectException(AssertionFailedError::class); |
|
2939
|
|
|
|
|
2940
|
|
|
$this->assertJsonStringNotEqualsJsonString($expected, $actual); |
|
2941
|
|
|
} |
|
2942
|
|
|
|
|
2943
|
|
|
public function testAssertJsonStringEqualsJsonFile() |
|
2944
|
|
|
{ |
|
2945
|
|
|
$file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
|
2946
|
|
|
$actual = \json_encode(['Mascott' => 'Tux']); |
|
2947
|
|
|
$message = ''; |
|
2948
|
|
|
|
|
2949
|
|
|
$this->assertJsonStringEqualsJsonFile($file, $actual, $message); |
|
2950
|
|
|
} |
|
2951
|
|
|
|
|
2952
|
|
|
public function testAssertJsonStringEqualsJsonFileExpectingExpectationFailedException() |
|
2953
|
|
|
{ |
|
2954
|
|
|
$file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
|
2955
|
|
|
$actual = \json_encode(['Mascott' => 'Beastie']); |
|
2956
|
|
|
$message = ''; |
|
2957
|
|
|
|
|
2958
|
|
|
try { |
|
2959
|
|
|
$this->assertJsonStringEqualsJsonFile($file, $actual, $message); |
|
2960
|
|
|
} catch (ExpectationFailedException $e) { |
|
2961
|
|
|
$this->assertEquals( |
|
2962
|
|
|
'Failed asserting that \'{"Mascott":"Beastie"}\' matches JSON string "{"Mascott":"Tux"}".', |
|
2963
|
|
|
$e->getMessage() |
|
2964
|
|
|
); |
|
2965
|
|
|
|
|
2966
|
|
|
return; |
|
2967
|
|
|
} |
|
2968
|
|
|
|
|
2969
|
|
|
$this->fail('Expected Exception not thrown.'); |
|
2970
|
|
|
} |
|
2971
|
|
|
|
|
2972
|
|
|
public function testAssertJsonStringEqualsJsonFileExpectingException() |
|
2973
|
|
|
{ |
|
2974
|
|
|
$file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
|
2975
|
|
|
|
|
2976
|
|
|
try { |
|
2977
|
|
|
$this->assertJsonStringEqualsJsonFile($file, null); |
|
2978
|
|
|
} catch (Exception $e) { |
|
2979
|
|
|
return; |
|
2980
|
|
|
} |
|
2981
|
|
|
|
|
2982
|
|
|
$this->fail('Expected Exception not thrown.'); |
|
2983
|
|
|
} |
|
2984
|
|
|
|
|
2985
|
|
|
public function testAssertJsonStringNotEqualsJsonFile() |
|
2986
|
|
|
{ |
|
2987
|
|
|
$file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
|
2988
|
|
|
$actual = \json_encode(['Mascott' => 'Beastie']); |
|
2989
|
|
|
$message = ''; |
|
2990
|
|
|
|
|
2991
|
|
|
$this->assertJsonStringNotEqualsJsonFile($file, $actual, $message); |
|
2992
|
|
|
} |
|
2993
|
|
|
|
|
2994
|
|
|
public function testAssertJsonStringNotEqualsJsonFileExpectingException() |
|
2995
|
|
|
{ |
|
2996
|
|
|
$file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
|
2997
|
|
|
|
|
2998
|
|
|
try { |
|
2999
|
|
|
$this->assertJsonStringNotEqualsJsonFile($file, null); |
|
3000
|
|
|
} catch (Exception $e) { |
|
3001
|
|
|
return; |
|
3002
|
|
|
} |
|
3003
|
|
|
|
|
3004
|
|
|
$this->fail('Expected exception not found.'); |
|
3005
|
|
|
} |
|
3006
|
|
|
|
|
3007
|
|
|
public function testAssertJsonFileNotEqualsJsonFile() |
|
3008
|
|
|
{ |
|
3009
|
|
|
$fileExpected = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
|
3010
|
|
|
$fileActual = __DIR__ . '/../_files/JsonData/arrayObject.json'; |
|
3011
|
|
|
$message = ''; |
|
3012
|
|
|
|
|
3013
|
|
|
$this->assertJsonFileNotEqualsJsonFile($fileExpected, $fileActual, $message); |
|
3014
|
|
|
} |
|
3015
|
|
|
|
|
3016
|
|
|
public function testAssertJsonFileEqualsJsonFile() |
|
3017
|
|
|
{ |
|
3018
|
|
|
$file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
|
3019
|
|
|
$message = ''; |
|
3020
|
|
|
|
|
3021
|
|
|
$this->assertJsonFileEqualsJsonFile($file, $file, $message); |
|
3022
|
|
|
} |
|
3023
|
|
|
|
|
3024
|
|
|
public function testAssertInstanceOf() |
|
3025
|
|
|
{ |
|
3026
|
|
|
$this->assertInstanceOf(\stdClass::class, new \stdClass); |
|
3027
|
|
|
|
|
3028
|
|
|
$this->expectException(AssertionFailedError::class); |
|
3029
|
|
|
|
|
3030
|
|
|
$this->assertInstanceOf(\Exception::class, new \stdClass); |
|
3031
|
|
|
} |
|
3032
|
|
|
|
|
3033
|
|
|
public function testAssertInstanceOfThrowsExceptionForInvalidArgument() |
|
3034
|
|
|
{ |
|
3035
|
|
|
$this->expectException(Exception::class); |
|
3036
|
|
|
|
|
3037
|
|
|
$this->assertInstanceOf(null, new \stdClass); |
|
3038
|
|
|
} |
|
3039
|
|
|
|
|
3040
|
|
|
public function testAssertAttributeInstanceOf() |
|
3041
|
|
|
{ |
|
3042
|
|
|
$o = new \stdClass; |
|
3043
|
|
|
$o->a = new \stdClass; |
|
3044
|
|
|
|
|
3045
|
|
|
$this->assertAttributeInstanceOf(\stdClass::class, 'a', $o); |
|
3046
|
|
|
} |
|
3047
|
|
|
|
|
3048
|
|
|
public function testAssertNotInstanceOf() |
|
3049
|
|
|
{ |
|
3050
|
|
|
$this->assertNotInstanceOf(\Exception::class, new \stdClass); |
|
3051
|
|
|
|
|
3052
|
|
|
$this->expectException(AssertionFailedError::class); |
|
3053
|
|
|
|
|
3054
|
|
|
$this->assertNotInstanceOf(\stdClass::class, new \stdClass); |
|
3055
|
|
|
} |
|
3056
|
|
|
|
|
3057
|
|
|
public function testAssertNotInstanceOfThrowsExceptionForInvalidArgument() |
|
3058
|
|
|
{ |
|
3059
|
|
|
$this->expectException(Exception::class); |
|
3060
|
|
|
|
|
3061
|
|
|
$this->assertNotInstanceOf(null, new \stdClass); |
|
3062
|
|
|
} |
|
3063
|
|
|
|
|
3064
|
|
|
public function testAssertAttributeNotInstanceOf() |
|
3065
|
|
|
{ |
|
3066
|
|
|
$o = new \stdClass; |
|
3067
|
|
|
$o->a = new \stdClass; |
|
3068
|
|
|
|
|
3069
|
|
|
$this->assertAttributeNotInstanceOf(\Exception::class, 'a', $o); |
|
3070
|
|
|
} |
|
3071
|
|
|
|
|
3072
|
|
|
public function testAssertInternalType() |
|
3073
|
|
|
{ |
|
3074
|
|
|
$this->assertInternalType('integer', 1); |
|
3075
|
|
|
|
|
3076
|
|
|
$this->expectException(AssertionFailedError::class); |
|
3077
|
|
|
|
|
3078
|
|
|
$this->assertInternalType('string', 1); |
|
3079
|
|
|
} |
|
3080
|
|
|
|
|
3081
|
|
|
public function testAssertInternalTypeDouble() |
|
3082
|
|
|
{ |
|
3083
|
|
|
$this->assertInternalType('double', 1.0); |
|
3084
|
|
|
|
|
3085
|
|
|
$this->expectException(AssertionFailedError::class); |
|
3086
|
|
|
|
|
3087
|
|
|
$this->assertInternalType('double', 1); |
|
3088
|
|
|
} |
|
3089
|
|
|
|
|
3090
|
|
|
public function testAssertInternalTypeThrowsExceptionForInvalidArgument() |
|
3091
|
|
|
{ |
|
3092
|
|
|
$this->expectException(Exception::class); |
|
3093
|
|
|
|
|
3094
|
|
|
$this->assertInternalType(null, 1); |
|
3095
|
|
|
} |
|
3096
|
|
|
|
|
3097
|
|
|
public function testAssertAttributeInternalType() |
|
3098
|
|
|
{ |
|
3099
|
|
|
$o = new \stdClass; |
|
3100
|
|
|
$o->a = 1; |
|
3101
|
|
|
|
|
3102
|
|
|
$this->assertAttributeInternalType('integer', 'a', $o); |
|
3103
|
|
|
} |
|
3104
|
|
|
|
|
3105
|
|
|
public function testAssertNotInternalType() |
|
3106
|
|
|
{ |
|
3107
|
|
|
$this->assertNotInternalType('string', 1); |
|
3108
|
|
|
|
|
3109
|
|
|
$this->expectException(AssertionFailedError::class); |
|
3110
|
|
|
|
|
3111
|
|
|
$this->assertNotInternalType('integer', 1); |
|
3112
|
|
|
} |
|
3113
|
|
|
|
|
3114
|
|
|
public function testAssertNotInternalTypeThrowsExceptionForInvalidArgument() |
|
3115
|
|
|
{ |
|
3116
|
|
|
$this->expectException(Exception::class); |
|
3117
|
|
|
|
|
3118
|
|
|
$this->assertNotInternalType(null, 1); |
|
3119
|
|
|
} |
|
3120
|
|
|
|
|
3121
|
|
|
public function testAssertAttributeNotInternalType() |
|
3122
|
|
|
{ |
|
3123
|
|
|
$o = new \stdClass; |
|
3124
|
|
|
$o->a = 1; |
|
3125
|
|
|
|
|
3126
|
|
|
$this->assertAttributeNotInternalType('string', 'a', $o); |
|
3127
|
|
|
} |
|
3128
|
|
|
|
|
3129
|
|
|
public function testAssertStringMatchesFormatFileThrowsExceptionForInvalidArgument() |
|
3130
|
|
|
{ |
|
3131
|
|
|
$this->expectException(Exception::class); |
|
3132
|
|
|
|
|
3133
|
|
|
$this->assertStringMatchesFormatFile('not_existing_file', ''); |
|
3134
|
|
|
} |
|
3135
|
|
|
|
|
3136
|
|
|
public function testAssertStringMatchesFormatFileThrowsExceptionForInvalidArgument2() |
|
3137
|
|
|
{ |
|
3138
|
|
|
$this->expectException(Exception::class); |
|
3139
|
|
|
|
|
3140
|
|
|
$this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', null); |
|
3141
|
|
|
} |
|
3142
|
|
|
|
|
3143
|
|
|
public function testAssertStringMatchesFormatFile() |
|
3144
|
|
|
{ |
|
3145
|
|
|
$this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "FOO\n"); |
|
3146
|
|
|
|
|
3147
|
|
|
$this->expectException(AssertionFailedError::class); |
|
3148
|
|
|
|
|
3149
|
|
|
$this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "BAR\n"); |
|
3150
|
|
|
} |
|
3151
|
|
|
|
|
3152
|
|
|
public function testAssertStringNotMatchesFormatFileThrowsExceptionForInvalidArgument() |
|
3153
|
|
|
{ |
|
3154
|
|
|
$this->expectException(Exception::class); |
|
3155
|
|
|
|
|
3156
|
|
|
$this->assertStringNotMatchesFormatFile('not_existing_file', ''); |
|
3157
|
|
|
} |
|
3158
|
|
|
|
|
3159
|
|
|
public function testAssertStringNotMatchesFormatFileThrowsExceptionForInvalidArgument2() |
|
3160
|
|
|
{ |
|
3161
|
|
|
$this->expectException(Exception::class); |
|
3162
|
|
|
|
|
3163
|
|
|
$this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', null); |
|
3164
|
|
|
} |
|
3165
|
|
|
|
|
3166
|
|
|
public function testAssertStringNotMatchesFormatFile() |
|
3167
|
|
|
{ |
|
3168
|
|
|
$this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "BAR\n"); |
|
3169
|
|
|
|
|
3170
|
|
|
$this->expectException(AssertionFailedError::class); |
|
3171
|
|
|
|
|
3172
|
|
|
$this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "FOO\n"); |
|
3173
|
|
|
} |
|
3174
|
|
|
|
|
3175
|
|
|
/** |
|
3176
|
|
|
* @return array |
|
3177
|
|
|
*/ |
|
3178
|
|
|
public static function validInvalidJsonDataprovider() |
|
3179
|
|
|
{ |
|
3180
|
|
|
return [ |
|
3181
|
|
|
'error syntax in expected JSON' => ['{"Mascott"::}', '{"Mascott" : "Tux"}'], |
|
3182
|
|
|
'error UTF-8 in actual JSON' => ['{"Mascott" : "Tux"}', '{"Mascott" : :}'], |
|
3183
|
|
|
]; |
|
3184
|
|
|
} |
|
3185
|
|
|
} |
|
3186
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: