Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Framework_AssertTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Framework_AssertTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class Framework_AssertTest extends PHPUnit_Framework_TestCase |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $filesDirectory; |
||
20 | |||
21 | protected function setUp() |
||
22 | { |
||
23 | $this->filesDirectory = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @covers PHPUnit_Framework_Assert::fail |
||
28 | */ |
||
29 | public function testFail() |
||
30 | { |
||
31 | try { |
||
32 | $this->fail(); |
||
33 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
34 | return; |
||
35 | } |
||
36 | |||
37 | throw new PHPUnit_Framework_AssertionFailedError('Fail did not throw fail exception'); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @covers PHPUnit_Framework_Assert::assertContains |
||
42 | */ |
||
43 | public function testAssertSplObjectStorageContainsObject() |
||
44 | { |
||
45 | $a = new stdClass; |
||
46 | $b = new stdClass; |
||
47 | $c = new SplObjectStorage; |
||
48 | $c->attach($a); |
||
49 | |||
50 | $this->assertContains($a, $c); |
||
51 | |||
52 | try { |
||
53 | $this->assertContains($b, $c); |
||
54 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
55 | return; |
||
56 | } |
||
57 | |||
58 | $this->fail(); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @covers PHPUnit_Framework_Assert::assertContains |
||
63 | */ |
||
64 | public function testAssertArrayContainsObject() |
||
65 | { |
||
66 | $a = new stdClass; |
||
67 | $b = new stdClass; |
||
68 | |||
69 | $this->assertContains($a, array($a)); |
||
70 | |||
71 | try { |
||
72 | $this->assertContains($a, array($b)); |
||
73 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
74 | return; |
||
75 | } |
||
76 | |||
77 | $this->fail(); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @covers PHPUnit_Framework_Assert::assertContains |
||
82 | */ |
||
83 | public function testAssertArrayContainsString() |
||
84 | { |
||
85 | $this->assertContains('foo', array('foo')); |
||
86 | |||
87 | try { |
||
88 | $this->assertContains('foo', array('bar')); |
||
89 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
90 | return; |
||
91 | } |
||
92 | |||
93 | $this->fail(); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @covers PHPUnit_Framework_Assert::assertContains |
||
98 | */ |
||
99 | public function testAssertArrayContainsNonObject() |
||
100 | { |
||
101 | $this->assertContains('foo', array(true)); |
||
102 | |||
103 | try { |
||
104 | $this->assertContains('foo', array(true), '', false, true, true); |
||
105 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
106 | return; |
||
107 | } |
||
108 | |||
109 | $this->fail(); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @covers PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf |
||
114 | */ |
||
115 | public function testAssertContainsOnlyInstancesOf() |
||
116 | { |
||
117 | $test = array( |
||
118 | new Book(), |
||
119 | new Book |
||
120 | ); |
||
121 | $this->assertContainsOnlyInstancesOf('Book', $test); |
||
122 | $this->assertContainsOnlyInstancesOf('stdClass', array(new stdClass())); |
||
123 | |||
124 | $test2 = array( |
||
125 | new Author('Test') |
||
126 | ); |
||
127 | try { |
||
128 | $this->assertContainsOnlyInstancesOf('Book', $test2); |
||
129 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
130 | return; |
||
131 | } |
||
132 | $this->fail(); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
137 | * @expectedException PHPUnit_Framework_Exception |
||
138 | */ |
||
139 | public function testAssertArrayHasKeyThrowsExceptionForInvalidFirstArgument() |
||
140 | { |
||
141 | $this->assertArrayHasKey(null, array()); |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
146 | * @expectedException PHPUnit_Framework_Exception |
||
147 | */ |
||
148 | public function testAssertArrayHasKeyThrowsExceptionForInvalidSecondArgument() |
||
149 | { |
||
150 | $this->assertArrayHasKey(0, null); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
155 | */ |
||
156 | public function testAssertArrayHasIntegerKey() |
||
157 | { |
||
158 | $this->assertArrayHasKey(0, array('foo')); |
||
159 | |||
160 | try { |
||
161 | $this->assertArrayHasKey(1, array('foo')); |
||
162 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
163 | return; |
||
164 | } |
||
165 | |||
166 | $this->fail(); |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * @covers PHPUnit_Framework_Assert::assertArraySubset |
||
171 | * @covers PHPUnit_Framework_Constraint_ArraySubset |
||
172 | */ |
||
173 | public function testAssertArraySubset() |
||
174 | { |
||
175 | $array = array( |
||
176 | 'a' => 'item a', |
||
177 | 'b' => 'item b', |
||
178 | 'c' => array('a2' => 'item a2', 'b2' => 'item b2'), |
||
179 | 'd' => array('a2' => array('a3' => 'item a3', 'b3' => 'item b3')) |
||
180 | ); |
||
181 | |||
182 | $this->assertArraySubset(array('a' => 'item a', 'c' => array('a2' => 'item a2')), $array); |
||
183 | $this->assertArraySubset(array('a' => 'item a', 'd' => array('a2' => array('b3' => 'item b3'))), $array); |
||
184 | |||
185 | try { |
||
186 | $this->assertArraySubset(array('a' => 'bad value'), $array); |
||
187 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
188 | } |
||
189 | |||
190 | try { |
||
191 | $this->assertArraySubset(array('d' => array('a2' => array('bad index' => 'item b3'))), $array); |
||
192 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
193 | return; |
||
194 | } |
||
195 | |||
196 | $this->fail(); |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * @covers PHPUnit_Framework_Assert::assertArraySubset |
||
201 | * @covers PHPUnit_Framework_Constraint_ArraySubset |
||
202 | */ |
||
203 | public function testAssertArraySubsetWithDeepNestedArrays() |
||
204 | { |
||
205 | $array = array( |
||
206 | 'path' => array( |
||
207 | 'to' => array( |
||
208 | 'the' => array( |
||
209 | 'cake' => 'is a lie' |
||
210 | ) |
||
211 | ) |
||
212 | ) |
||
213 | ); |
||
214 | |||
215 | $this->assertArraySubset(array('path' => array()), $array); |
||
216 | $this->assertArraySubset(array('path' => array('to' => array())), $array); |
||
217 | $this->assertArraySubset(array('path' => array('to' => array('the' => array()))), $array); |
||
218 | $this->assertArraySubset(array('path' => array('to' => array('the' => array('cake' => 'is a lie')))), $array); |
||
219 | |||
220 | try { |
||
221 | $this->assertArraySubset(array('path' => array('to' => array('the' => array('cake' => 'is not a lie')))), $array); |
||
222 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
223 | return; |
||
224 | } |
||
225 | |||
226 | $this->fail(); |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @covers PHPUnit_Framework_Assert::assertArraySubset |
||
231 | * @covers PHPUnit_Framework_Constraint_ArraySubset |
||
232 | */ |
||
233 | public function testAssertArraySubsetWithNoStrictCheckAndObjects() |
||
234 | { |
||
235 | $obj = new \stdClass; |
||
236 | $reference = &$obj; |
||
237 | $array = array('a' => $obj); |
||
238 | |||
239 | $this->assertArraySubset(array('a' => $reference), $array); |
||
240 | $this->assertArraySubset(array('a' => new \stdClass), $array); |
||
241 | } |
||
242 | |||
243 | /** |
||
244 | * @covers PHPUnit_Framework_Assert::assertArraySubset |
||
245 | * @covers PHPUnit_Framework_Constraint_ArraySubset |
||
246 | */ |
||
247 | public function testAssertArraySubsetWithStrictCheckAndObjects() |
||
248 | { |
||
249 | $obj = new \stdClass; |
||
250 | $reference = &$obj; |
||
251 | $array = array('a' => $obj); |
||
252 | |||
253 | $this->assertArraySubset(array('a' => $reference), $array, true); |
||
254 | |||
255 | try { |
||
256 | $this->assertArraySubset(array('a' => new \stdClass), $array, true); |
||
257 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
258 | return; |
||
259 | } |
||
260 | |||
261 | $this->fail('Strict recursive array check fail.'); |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * @covers PHPUnit_Framework_Assert::assertArraySubset |
||
266 | * @covers PHPUnit_Framework_Constraint_ArraySubset |
||
267 | * @expectedException PHPUnit_Framework_Exception |
||
268 | * @expectedExceptionMessage array or ArrayAccess |
||
269 | * @dataProvider assertArraySubsetInvalidArgumentProvider |
||
270 | */ |
||
271 | public function testAssertArraySubsetRaisesExceptionForInvalidArguments($partial, $subject) |
||
272 | { |
||
273 | $this->assertArraySubset($partial, $subject); |
||
274 | } |
||
275 | |||
276 | /** |
||
277 | * @return array |
||
278 | */ |
||
279 | public function assertArraySubsetInvalidArgumentProvider() |
||
280 | { |
||
281 | return array( |
||
282 | array(false, array()), |
||
283 | array(array(), false), |
||
284 | ); |
||
285 | } |
||
286 | |||
287 | /** |
||
288 | * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey |
||
289 | * @expectedException PHPUnit_Framework_Exception |
||
290 | */ |
||
291 | public function testAssertArrayNotHasKeyThrowsExceptionForInvalidFirstArgument() |
||
292 | { |
||
293 | $this->assertArrayNotHasKey(null, array()); |
||
294 | } |
||
295 | |||
296 | /** |
||
297 | * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey |
||
298 | * @expectedException PHPUnit_Framework_Exception |
||
299 | */ |
||
300 | public function testAssertArrayNotHasKeyThrowsExceptionForInvalidSecondArgument() |
||
301 | { |
||
302 | $this->assertArrayNotHasKey(0, null); |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey |
||
307 | */ |
||
308 | public function testAssertArrayNotHasIntegerKey() |
||
309 | { |
||
310 | $this->assertArrayNotHasKey(1, array('foo')); |
||
311 | |||
312 | try { |
||
313 | $this->assertArrayNotHasKey(0, array('foo')); |
||
314 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
315 | return; |
||
316 | } |
||
317 | |||
318 | $this->fail(); |
||
319 | } |
||
320 | |||
321 | /** |
||
322 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
323 | */ |
||
324 | public function testAssertArrayHasStringKey() |
||
325 | { |
||
326 | $this->assertArrayHasKey('foo', array('foo' => 'bar')); |
||
327 | |||
328 | try { |
||
329 | $this->assertArrayHasKey('bar', array('foo' => 'bar')); |
||
330 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
331 | return; |
||
332 | } |
||
333 | |||
334 | $this->fail(); |
||
335 | } |
||
336 | |||
337 | /** |
||
338 | * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey |
||
339 | */ |
||
340 | public function testAssertArrayNotHasStringKey() |
||
341 | { |
||
342 | $this->assertArrayNotHasKey('bar', array('foo' => 'bar')); |
||
343 | |||
344 | try { |
||
345 | $this->assertArrayNotHasKey('foo', array('foo' => 'bar')); |
||
346 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
347 | return; |
||
348 | } |
||
349 | |||
350 | $this->fail(); |
||
351 | } |
||
352 | |||
353 | /** |
||
354 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
355 | */ |
||
356 | public function testAssertArrayHasKeyAcceptsArrayObjectValue() |
||
357 | { |
||
358 | $array = new ArrayObject(); |
||
359 | $array['foo'] = 'bar'; |
||
360 | $this->assertArrayHasKey('foo', $array); |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
365 | * @expectedException PHPUnit_Framework_AssertionFailedError |
||
366 | */ |
||
367 | public function testAssertArrayHasKeyProperlyFailsWithArrayObjectValue() |
||
368 | { |
||
369 | $array = new ArrayObject(); |
||
370 | $array['bar'] = 'bar'; |
||
371 | $this->assertArrayHasKey('foo', $array); |
||
372 | } |
||
373 | |||
374 | /** |
||
375 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
376 | */ |
||
377 | public function testAssertArrayHasKeyAcceptsArrayAccessValue() |
||
378 | { |
||
379 | $array = new SampleArrayAccess(); |
||
380 | $array['foo'] = 'bar'; |
||
381 | $this->assertArrayHasKey('foo', $array); |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * @covers PHPUnit_Framework_Assert::assertArrayHasKey |
||
386 | * @expectedException PHPUnit_Framework_AssertionFailedError |
||
387 | */ |
||
388 | public function testAssertArrayHasKeyProperlyFailsWithArrayAccessValue() |
||
389 | { |
||
390 | $array = new SampleArrayAccess(); |
||
391 | $array['bar'] = 'bar'; |
||
392 | $this->assertArrayHasKey('foo', $array); |
||
393 | } |
||
394 | |||
395 | /** |
||
396 | * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey |
||
397 | */ |
||
398 | public function testAssertArrayNotHasKeyAcceptsArrayAccessValue() |
||
399 | { |
||
400 | $array = new ArrayObject(); |
||
401 | $array['foo'] = 'bar'; |
||
402 | $this->assertArrayNotHasKey('bar', $array); |
||
403 | } |
||
404 | |||
405 | /** |
||
406 | * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey |
||
407 | * @expectedException PHPUnit_Framework_AssertionFailedError |
||
408 | */ |
||
409 | public function testAssertArrayNotHasKeyPropertlyFailsWithArrayAccessValue() |
||
410 | { |
||
411 | $array = new ArrayObject(); |
||
412 | $array['bar'] = 'bar'; |
||
413 | $this->assertArrayNotHasKey('bar', $array); |
||
414 | } |
||
415 | |||
416 | /** |
||
417 | * @covers PHPUnit_Framework_Assert::assertContains |
||
418 | * @expectedException PHPUnit_Framework_Exception |
||
419 | */ |
||
420 | public function testAssertContainsThrowsException() |
||
421 | { |
||
422 | $this->assertContains(null, null); |
||
423 | } |
||
424 | |||
425 | /** |
||
426 | * @covers PHPUnit_Framework_Assert::assertContains |
||
427 | */ |
||
428 | public function testAssertIteratorContainsObject() |
||
429 | { |
||
430 | $foo = new stdClass; |
||
431 | |||
432 | $this->assertContains($foo, new TestIterator(array($foo))); |
||
433 | |||
434 | try { |
||
435 | $this->assertContains($foo, new TestIterator(array(new stdClass))); |
||
436 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
437 | return; |
||
438 | } |
||
439 | |||
440 | $this->fail(); |
||
441 | } |
||
442 | |||
443 | /** |
||
444 | * @covers PHPUnit_Framework_Assert::assertContains |
||
445 | */ |
||
446 | public function testAssertIteratorContainsString() |
||
447 | { |
||
448 | $this->assertContains('foo', new TestIterator(array('foo'))); |
||
449 | |||
450 | try { |
||
451 | $this->assertContains('foo', new TestIterator(array('bar'))); |
||
452 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
453 | return; |
||
454 | } |
||
455 | |||
456 | $this->fail(); |
||
457 | } |
||
458 | |||
459 | /** |
||
460 | * @covers PHPUnit_Framework_Assert::assertContains |
||
461 | */ |
||
462 | public function testAssertStringContainsString() |
||
463 | { |
||
464 | $this->assertContains('foo', 'foobar'); |
||
465 | |||
466 | try { |
||
467 | $this->assertContains('foo', 'bar'); |
||
468 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
469 | return; |
||
470 | } |
||
471 | |||
472 | $this->fail(); |
||
473 | } |
||
474 | |||
475 | /** |
||
476 | * @covers PHPUnit_Framework_Assert::assertNotContains |
||
477 | * @expectedException PHPUnit_Framework_Exception |
||
478 | */ |
||
479 | public function testAssertNotContainsThrowsException() |
||
480 | { |
||
481 | $this->assertNotContains(null, null); |
||
482 | } |
||
483 | |||
484 | /** |
||
485 | * @covers PHPUnit_Framework_Assert::assertNotContains |
||
486 | */ |
||
487 | public function testAssertSplObjectStorageNotContainsObject() |
||
488 | { |
||
489 | $a = new stdClass; |
||
490 | $b = new stdClass; |
||
491 | $c = new SplObjectStorage; |
||
492 | $c->attach($a); |
||
493 | |||
494 | $this->assertNotContains($b, $c); |
||
495 | |||
496 | try { |
||
497 | $this->assertNotContains($a, $c); |
||
498 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
499 | return; |
||
500 | } |
||
501 | |||
502 | $this->fail(); |
||
503 | } |
||
504 | |||
505 | /** |
||
506 | * @covers PHPUnit_Framework_Assert::assertNotContains |
||
507 | */ |
||
508 | public function testAssertArrayNotContainsObject() |
||
509 | { |
||
510 | $a = new stdClass; |
||
511 | $b = new stdClass; |
||
512 | |||
513 | $this->assertNotContains($a, array($b)); |
||
514 | |||
515 | try { |
||
516 | $this->assertNotContains($a, array($a)); |
||
517 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
518 | return; |
||
519 | } |
||
520 | |||
521 | $this->fail(); |
||
522 | } |
||
523 | |||
524 | /** |
||
525 | * @covers PHPUnit_Framework_Assert::assertNotContains |
||
526 | */ |
||
527 | public function testAssertArrayNotContainsString() |
||
528 | { |
||
529 | $this->assertNotContains('foo', array('bar')); |
||
530 | |||
531 | try { |
||
532 | $this->assertNotContains('foo', array('foo')); |
||
533 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
534 | return; |
||
535 | } |
||
536 | |||
537 | $this->fail(); |
||
538 | } |
||
539 | |||
540 | /** |
||
541 | * @covers PHPUnit_Framework_Assert::assertNotContains |
||
542 | */ |
||
543 | public function testAssertArrayNotContainsNonObject() |
||
544 | { |
||
545 | $this->assertNotContains('foo', array(true), '', false, true, true); |
||
546 | |||
547 | try { |
||
548 | $this->assertNotContains('foo', array(true)); |
||
549 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
550 | return; |
||
551 | } |
||
552 | |||
553 | $this->fail(); |
||
554 | } |
||
555 | |||
556 | /** |
||
557 | * @covers PHPUnit_Framework_Assert::assertNotContains |
||
558 | */ |
||
559 | public function testAssertStringNotContainsString() |
||
560 | { |
||
561 | $this->assertNotContains('foo', 'bar'); |
||
562 | |||
563 | try { |
||
564 | $this->assertNotContains('foo', 'foo'); |
||
565 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
566 | return; |
||
567 | } |
||
568 | |||
569 | $this->fail(); |
||
570 | } |
||
571 | |||
572 | /** |
||
573 | * @covers PHPUnit_Framework_Assert::assertContainsOnly |
||
574 | * @expectedException PHPUnit_Framework_Exception |
||
575 | */ |
||
576 | public function testAssertContainsOnlyThrowsException() |
||
577 | { |
||
578 | $this->assertContainsOnly(null, null); |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * @covers PHPUnit_Framework_Assert::assertNotContainsOnly |
||
583 | * @expectedException PHPUnit_Framework_Exception |
||
584 | */ |
||
585 | public function testAssertNotContainsOnlyThrowsException() |
||
586 | { |
||
587 | $this->assertNotContainsOnly(null, null); |
||
588 | } |
||
589 | |||
590 | /** |
||
591 | * @covers PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf |
||
592 | * @expectedException PHPUnit_Framework_Exception |
||
593 | */ |
||
594 | public function testAssertContainsOnlyInstancesOfThrowsException() |
||
595 | { |
||
596 | $this->assertContainsOnlyInstancesOf(null, null); |
||
597 | } |
||
598 | |||
599 | /** |
||
600 | * @covers PHPUnit_Framework_Assert::assertContainsOnly |
||
601 | */ |
||
602 | public function testAssertArrayContainsOnlyIntegers() |
||
603 | { |
||
604 | $this->assertContainsOnly('integer', array(1, 2, 3)); |
||
605 | |||
606 | try { |
||
607 | $this->assertContainsOnly('integer', array('1', 2, 3)); |
||
608 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
609 | return; |
||
610 | } |
||
611 | |||
612 | $this->fail(); |
||
613 | } |
||
614 | |||
615 | /** |
||
616 | * @covers PHPUnit_Framework_Assert::assertNotContainsOnly |
||
617 | */ |
||
618 | public function testAssertArrayNotContainsOnlyIntegers() |
||
619 | { |
||
620 | $this->assertNotContainsOnly('integer', array('1', 2, 3)); |
||
621 | |||
622 | try { |
||
623 | $this->assertNotContainsOnly('integer', array(1, 2, 3)); |
||
624 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
625 | return; |
||
626 | } |
||
627 | |||
628 | $this->fail(); |
||
629 | } |
||
630 | |||
631 | /** |
||
632 | * @covers PHPUnit_Framework_Assert::assertContainsOnly |
||
633 | */ |
||
634 | public function testAssertArrayContainsOnlyStdClass() |
||
635 | { |
||
636 | $this->assertContainsOnly('StdClass', array(new stdClass)); |
||
637 | |||
638 | try { |
||
639 | $this->assertContainsOnly('StdClass', array('StdClass')); |
||
640 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
641 | return; |
||
642 | } |
||
643 | |||
644 | $this->fail(); |
||
645 | } |
||
646 | |||
647 | /** |
||
648 | * @covers PHPUnit_Framework_Assert::assertNotContainsOnly |
||
649 | */ |
||
650 | public function testAssertArrayNotContainsOnlyStdClass() |
||
651 | { |
||
652 | $this->assertNotContainsOnly('StdClass', array('StdClass')); |
||
653 | |||
654 | try { |
||
655 | $this->assertNotContainsOnly('StdClass', array(new stdClass)); |
||
656 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
657 | return; |
||
658 | } |
||
659 | |||
660 | $this->fail(); |
||
661 | } |
||
662 | |||
663 | protected function sameValues() |
||
664 | { |
||
665 | $object = new SampleClass(4, 8, 15); |
||
666 | // cannot use $filesDirectory, because neither setUp() nor |
||
667 | // setUpBeforeClass() are executed before the data providers |
||
668 | $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'foo.xml'; |
||
669 | $resource = fopen($file, 'r'); |
||
670 | |||
671 | return array( |
||
672 | // null |
||
673 | array(null, null), |
||
674 | // strings |
||
675 | array('a', 'a'), |
||
676 | // integers |
||
677 | array(0, 0), |
||
678 | // floats |
||
679 | array(2.3, 2.3), |
||
680 | array(1/3, 1 - 2/3), |
||
681 | array(log(0), log(0)), |
||
682 | // arrays |
||
683 | array(array(), array()), |
||
684 | array(array(0 => 1), array(0 => 1)), |
||
685 | array(array(0 => null), array(0 => null)), |
||
686 | array(array('a', 'b' => array(1, 2)), array('a', 'b' => array(1, 2))), |
||
687 | // objects |
||
688 | array($object, $object), |
||
689 | // resources |
||
690 | array($resource, $resource), |
||
691 | ); |
||
692 | } |
||
693 | |||
694 | protected function notEqualValues() |
||
695 | { |
||
696 | // cyclic dependencies |
||
697 | $book1 = new Book; |
||
698 | $book1->author = new Author('Terry Pratchett'); |
||
699 | $book1->author->books[] = $book1; |
||
700 | $book2 = new Book; |
||
701 | $book2->author = new Author('Terry Pratch'); |
||
702 | $book2->author->books[] = $book2; |
||
703 | |||
704 | $book3 = new Book; |
||
705 | $book3->author = 'Terry Pratchett'; |
||
706 | $book4 = new stdClass; |
||
707 | $book4->author = 'Terry Pratchett'; |
||
708 | |||
709 | $object1 = new SampleClass(4, 8, 15); |
||
710 | $object2 = new SampleClass(16, 23, 42); |
||
711 | $object3 = new SampleClass(4, 8, 15); |
||
712 | $storage1 = new SplObjectStorage; |
||
713 | $storage1->attach($object1); |
||
714 | $storage2 = new SplObjectStorage; |
||
715 | $storage2->attach($object3); // same content, different object |
||
716 | |||
717 | // cannot use $filesDirectory, because neither setUp() nor |
||
718 | // setUpBeforeClass() are executed before the data providers |
||
719 | $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'foo.xml'; |
||
720 | |||
721 | return array( |
||
722 | // strings |
||
723 | array('a', 'b'), |
||
724 | array('a', 'A'), |
||
725 | // https://github.com/sebastianbergmann/phpunit/issues/1023 |
||
726 | array('9E6666666','9E7777777'), |
||
727 | // integers |
||
728 | array(1, 2), |
||
729 | array(2, 1), |
||
730 | // floats |
||
731 | array(2.3, 4.2), |
||
732 | array(2.3, 4.2, 0.5), |
||
733 | array(array(2.3), array(4.2), 0.5), |
||
734 | array(array(array(2.3)), array(array(4.2)), 0.5), |
||
735 | array(new Struct(2.3), new Struct(4.2), 0.5), |
||
736 | array(array(new Struct(2.3)), array(new Struct(4.2)), 0.5), |
||
737 | // NAN |
||
738 | array(NAN, NAN), |
||
739 | // arrays |
||
740 | array(array(), array(0 => 1)), |
||
741 | array(array(0 => 1), array()), |
||
742 | array(array(0 => null), array()), |
||
743 | array(array(0 => 1, 1 => 2), array(0 => 1, 1 => 3)), |
||
744 | array(array('a', 'b' => array(1, 2)), array('a', 'b' => array(2, 1))), |
||
745 | // objects |
||
746 | array(new SampleClass(4, 8, 15), new SampleClass(16, 23, 42)), |
||
747 | array($object1, $object2), |
||
748 | array($book1, $book2), |
||
749 | array($book3, $book4), // same content, different class |
||
750 | // resources |
||
751 | array(fopen($file, 'r'), fopen($file, 'r')), |
||
752 | // SplObjectStorage |
||
753 | array($storage1, $storage2), |
||
754 | // DOMDocument |
||
755 | array( |
||
756 | PHPUnit_Util_XML::load('<root></root>'), |
||
757 | PHPUnit_Util_XML::load('<bar/>'), |
||
758 | ), |
||
759 | array( |
||
760 | PHPUnit_Util_XML::load('<foo attr1="bar"/>'), |
||
761 | PHPUnit_Util_XML::load('<foo attr1="foobar"/>'), |
||
762 | ), |
||
763 | array( |
||
764 | PHPUnit_Util_XML::load('<foo> bar </foo>'), |
||
765 | PHPUnit_Util_XML::load('<foo />'), |
||
766 | ), |
||
767 | array( |
||
768 | PHPUnit_Util_XML::load('<foo xmlns="urn:myns:bar"/>'), |
||
769 | PHPUnit_Util_XML::load('<foo xmlns="urn:notmyns:bar"/>'), |
||
770 | ), |
||
771 | array( |
||
772 | PHPUnit_Util_XML::load('<foo> bar </foo>'), |
||
773 | PHPUnit_Util_XML::load('<foo> bir </foo>'), |
||
774 | ), |
||
775 | array( |
||
776 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
777 | new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/New_York')), |
||
778 | ), |
||
779 | array( |
||
780 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
781 | new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/New_York')), |
||
782 | 3500 |
||
783 | ), |
||
784 | array( |
||
785 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
786 | new DateTime('2013-03-29 05:13:35', new DateTimeZone('America/New_York')), |
||
787 | 3500 |
||
788 | ), |
||
789 | array( |
||
790 | new DateTime('2013-03-29', new DateTimeZone('America/New_York')), |
||
791 | new DateTime('2013-03-30', new DateTimeZone('America/New_York')), |
||
792 | ), |
||
793 | array( |
||
794 | new DateTime('2013-03-29', new DateTimeZone('America/New_York')), |
||
795 | new DateTime('2013-03-30', new DateTimeZone('America/New_York')), |
||
796 | 43200 |
||
797 | ), |
||
798 | array( |
||
799 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
800 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/Chicago')), |
||
801 | ), |
||
802 | array( |
||
803 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
804 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/Chicago')), |
||
805 | 3500 |
||
806 | ), |
||
807 | array( |
||
808 | new DateTime('2013-03-30', new DateTimeZone('America/New_York')), |
||
809 | new DateTime('2013-03-30', new DateTimeZone('America/Chicago')), |
||
810 | ), |
||
811 | array( |
||
812 | new DateTime('2013-03-29T05:13:35-0600'), |
||
813 | new DateTime('2013-03-29T04:13:35-0600'), |
||
814 | ), |
||
815 | array( |
||
816 | new DateTime('2013-03-29T05:13:35-0600'), |
||
817 | new DateTime('2013-03-29T05:13:35-0500'), |
||
818 | ), |
||
819 | // Exception |
||
820 | //array(new Exception('Exception 1'), new Exception('Exception 2')), |
||
821 | // different types |
||
822 | array(new SampleClass(4, 8, 15), false), |
||
823 | array(false, new SampleClass(4, 8, 15)), |
||
824 | array(array(0 => 1, 1 => 2), false), |
||
825 | array(false, array(0 => 1, 1 => 2)), |
||
826 | array(array(), new stdClass), |
||
827 | array(new stdClass, array()), |
||
828 | // PHP: 0 == 'Foobar' => true! |
||
829 | // We want these values to differ |
||
830 | array(0, 'Foobar'), |
||
831 | array('Foobar', 0), |
||
832 | array(3, acos(8)), |
||
833 | array(acos(8), 3) |
||
834 | ); |
||
835 | } |
||
836 | |||
837 | protected function equalValues() |
||
838 | { |
||
839 | // cyclic dependencies |
||
840 | $book1 = new Book; |
||
841 | $book1->author = new Author('Terry Pratchett'); |
||
842 | $book1->author->books[] = $book1; |
||
843 | $book2 = new Book; |
||
844 | $book2->author = new Author('Terry Pratchett'); |
||
845 | $book2->author->books[] = $book2; |
||
846 | |||
847 | $object1 = new SampleClass(4, 8, 15); |
||
848 | $object2 = new SampleClass(4, 8, 15); |
||
849 | $storage1 = new SplObjectStorage; |
||
850 | $storage1->attach($object1); |
||
851 | $storage2 = new SplObjectStorage; |
||
852 | $storage2->attach($object1); |
||
853 | |||
854 | return array( |
||
855 | // strings |
||
856 | array('a', 'A', 0, false, true), // ignore case |
||
857 | // arrays |
||
858 | array(array('a' => 1, 'b' => 2), array('b' => 2, 'a' => 1)), |
||
859 | array(array(1), array('1')), |
||
860 | array(array(3, 2, 1), array(2, 3, 1), 0, true), // canonicalized comparison |
||
861 | // floats |
||
862 | array(2.3, 2.5, 0.5), |
||
863 | array(array(2.3), array(2.5), 0.5), |
||
864 | array(array(array(2.3)), array(array(2.5)), 0.5), |
||
865 | array(new Struct(2.3), new Struct(2.5), 0.5), |
||
866 | array(array(new Struct(2.3)), array(new Struct(2.5)), 0.5), |
||
867 | // numeric with delta |
||
868 | array(1, 2, 1), |
||
869 | // objects |
||
870 | array($object1, $object2), |
||
871 | array($book1, $book2), |
||
872 | // SplObjectStorage |
||
873 | array($storage1, $storage2), |
||
874 | // DOMDocument |
||
875 | array( |
||
876 | PHPUnit_Util_XML::load('<root></root>'), |
||
877 | PHPUnit_Util_XML::load('<root/>'), |
||
878 | ), |
||
879 | array( |
||
880 | PHPUnit_Util_XML::load('<root attr="bar"></root>'), |
||
881 | PHPUnit_Util_XML::load('<root attr="bar"/>'), |
||
882 | ), |
||
883 | array( |
||
884 | PHPUnit_Util_XML::load('<root><foo attr="bar"></foo></root>'), |
||
885 | PHPUnit_Util_XML::load('<root><foo attr="bar"/></root>'), |
||
886 | ), |
||
887 | array( |
||
888 | PHPUnit_Util_XML::load("<root>\n <child/>\n</root>"), |
||
889 | PHPUnit_Util_XML::load('<root><child/></root>'), |
||
890 | ), |
||
891 | array( |
||
892 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
893 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
894 | ), |
||
895 | array( |
||
896 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
897 | new DateTime('2013-03-29 04:13:25', new DateTimeZone('America/New_York')), |
||
898 | 10 |
||
899 | ), |
||
900 | array( |
||
901 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
902 | new DateTime('2013-03-29 04:14:40', new DateTimeZone('America/New_York')), |
||
903 | 65 |
||
904 | ), |
||
905 | array( |
||
906 | new DateTime('2013-03-29', new DateTimeZone('America/New_York')), |
||
907 | new DateTime('2013-03-29', new DateTimeZone('America/New_York')), |
||
908 | ), |
||
909 | array( |
||
910 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
911 | new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/Chicago')), |
||
912 | ), |
||
913 | array( |
||
914 | new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')), |
||
915 | new DateTime('2013-03-29 03:13:49', new DateTimeZone('America/Chicago')), |
||
916 | 15 |
||
917 | ), |
||
918 | array( |
||
919 | new DateTime('2013-03-30', new DateTimeZone('America/New_York')), |
||
920 | new DateTime('2013-03-29 23:00:00', new DateTimeZone('America/Chicago')), |
||
921 | ), |
||
922 | array( |
||
923 | new DateTime('2013-03-30', new DateTimeZone('America/New_York')), |
||
924 | new DateTime('2013-03-29 23:01:30', new DateTimeZone('America/Chicago')), |
||
925 | 100 |
||
926 | ), |
||
927 | array( |
||
928 | new DateTime('@1364616000'), |
||
929 | new DateTime('2013-03-29 23:00:00', new DateTimeZone('America/Chicago')), |
||
930 | ), |
||
931 | array( |
||
932 | new DateTime('2013-03-29T05:13:35-0500'), |
||
933 | new DateTime('2013-03-29T04:13:35-0600'), |
||
934 | ), |
||
935 | // Exception |
||
936 | //array(new Exception('Exception 1'), new Exception('Exception 1')), |
||
937 | // mixed types |
||
938 | array(0, '0'), |
||
939 | array('0', 0), |
||
940 | array(2.3, '2.3'), |
||
941 | array('2.3', 2.3), |
||
942 | array((string) (1/3), 1 - 2/3), |
||
943 | array(1/3, (string) (1 - 2/3)), |
||
944 | array('string representation', new ClassWithToString), |
||
945 | array(new ClassWithToString, 'string representation'), |
||
946 | ); |
||
947 | } |
||
948 | |||
949 | public function equalProvider() |
||
950 | { |
||
951 | // same |= equal |
||
952 | return array_merge($this->equalValues(), $this->sameValues()); |
||
953 | } |
||
954 | |||
955 | public function notEqualProvider() |
||
956 | { |
||
957 | return $this->notEqualValues(); |
||
958 | } |
||
959 | |||
960 | public function sameProvider() |
||
961 | { |
||
962 | return $this->sameValues(); |
||
963 | } |
||
964 | |||
965 | public function notSameProvider() |
||
966 | { |
||
967 | // not equal |= not same |
||
968 | // equal, ¬same |= not same |
||
969 | return array_merge($this->notEqualValues(), $this->equalValues()); |
||
970 | } |
||
971 | |||
972 | /** |
||
973 | * @covers PHPUnit_Framework_Assert::assertEquals |
||
974 | * @dataProvider equalProvider |
||
975 | */ |
||
976 | public function testAssertEqualsSucceeds($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
||
977 | { |
||
978 | $this->assertEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
||
979 | } |
||
980 | |||
981 | /** |
||
982 | * @covers PHPUnit_Framework_Assert::assertEquals |
||
983 | * @dataProvider notEqualProvider |
||
984 | */ |
||
985 | public function testAssertEqualsFails($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
||
986 | { |
||
987 | try { |
||
988 | $this->assertEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
||
989 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
990 | return; |
||
991 | } |
||
992 | |||
993 | $this->fail(); |
||
994 | } |
||
995 | |||
996 | /** |
||
997 | * @covers PHPUnit_Framework_Assert::assertNotEquals |
||
998 | * @dataProvider notEqualProvider |
||
999 | */ |
||
1000 | public function testAssertNotEqualsSucceeds($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
||
1001 | { |
||
1002 | $this->assertNotEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
||
1003 | } |
||
1004 | |||
1005 | /** |
||
1006 | * @covers PHPUnit_Framework_Assert::assertNotEquals |
||
1007 | * @dataProvider equalProvider |
||
1008 | */ |
||
1009 | public function testAssertNotEqualsFails($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false) |
||
1010 | { |
||
1011 | try { |
||
1012 | $this->assertNotEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase); |
||
1013 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1014 | return; |
||
1015 | } |
||
1016 | |||
1017 | $this->fail(); |
||
1018 | } |
||
1019 | |||
1020 | /** |
||
1021 | * @covers PHPUnit_Framework_Assert::assertSame |
||
1022 | * @dataProvider sameProvider |
||
1023 | */ |
||
1024 | public function testAssertSameSucceeds($a, $b) |
||
1025 | { |
||
1026 | $this->assertSame($a, $b); |
||
1027 | } |
||
1028 | |||
1029 | /** |
||
1030 | * @covers PHPUnit_Framework_Assert::assertSame |
||
1031 | * @dataProvider notSameProvider |
||
1032 | */ |
||
1033 | public function testAssertSameFails($a, $b) |
||
1034 | { |
||
1035 | try { |
||
1036 | $this->assertSame($a, $b); |
||
1037 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1038 | return; |
||
1039 | } |
||
1040 | |||
1041 | $this->fail(); |
||
1042 | } |
||
1043 | |||
1044 | /** |
||
1045 | * @covers PHPUnit_Framework_Assert::assertNotSame |
||
1046 | * @dataProvider notSameProvider |
||
1047 | */ |
||
1048 | public function testAssertNotSameSucceeds($a, $b) |
||
1049 | { |
||
1050 | $this->assertNotSame($a, $b); |
||
1051 | } |
||
1052 | |||
1053 | /** |
||
1054 | * @covers PHPUnit_Framework_Assert::assertNotSame |
||
1055 | * @dataProvider sameProvider |
||
1056 | */ |
||
1057 | public function testAssertNotSameFails($a, $b) |
||
1058 | { |
||
1059 | try { |
||
1060 | $this->assertNotSame($a, $b); |
||
1061 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1062 | return; |
||
1063 | } |
||
1064 | |||
1065 | $this->fail(); |
||
1066 | } |
||
1067 | |||
1068 | /** |
||
1069 | * @covers PHPUnit_Framework_Assert::assertXmlFileEqualsXmlFile |
||
1070 | */ |
||
1071 | public function testAssertXmlFileEqualsXmlFile() |
||
1072 | { |
||
1073 | $this->assertXmlFileEqualsXmlFile( |
||
1074 | $this->filesDirectory . 'foo.xml', |
||
1075 | $this->filesDirectory . 'foo.xml' |
||
1076 | ); |
||
1077 | |||
1078 | try { |
||
1079 | $this->assertXmlFileEqualsXmlFile( |
||
1080 | $this->filesDirectory . 'foo.xml', |
||
1081 | $this->filesDirectory . 'bar.xml' |
||
1082 | ); |
||
1083 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1084 | return; |
||
1085 | } |
||
1086 | |||
1087 | $this->fail(); |
||
1088 | } |
||
1089 | |||
1090 | /** |
||
1091 | * @covers PHPUnit_Framework_Assert::assertXmlFileNotEqualsXmlFile |
||
1092 | */ |
||
1093 | public function testAssertXmlFileNotEqualsXmlFile() |
||
1094 | { |
||
1095 | $this->assertXmlFileNotEqualsXmlFile( |
||
1096 | $this->filesDirectory . 'foo.xml', |
||
1097 | $this->filesDirectory . 'bar.xml' |
||
1098 | ); |
||
1099 | |||
1100 | try { |
||
1101 | $this->assertXmlFileNotEqualsXmlFile( |
||
1102 | $this->filesDirectory . 'foo.xml', |
||
1103 | $this->filesDirectory . 'foo.xml' |
||
1104 | ); |
||
1105 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1106 | return; |
||
1107 | } |
||
1108 | |||
1109 | $this->fail(); |
||
1110 | } |
||
1111 | |||
1112 | /** |
||
1113 | * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile |
||
1114 | */ |
||
1115 | public function testAssertXmlStringEqualsXmlFile() |
||
1116 | { |
||
1117 | $this->assertXmlStringEqualsXmlFile( |
||
1118 | $this->filesDirectory . 'foo.xml', |
||
1119 | file_get_contents($this->filesDirectory . 'foo.xml') |
||
1120 | ); |
||
1121 | |||
1122 | try { |
||
1123 | $this->assertXmlStringEqualsXmlFile( |
||
1124 | $this->filesDirectory . 'foo.xml', |
||
1125 | file_get_contents($this->filesDirectory . 'bar.xml') |
||
1126 | ); |
||
1127 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1128 | return; |
||
1129 | } |
||
1130 | |||
1131 | $this->fail(); |
||
1132 | } |
||
1133 | |||
1134 | /** |
||
1135 | * @covers PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlFile |
||
1136 | */ |
||
1137 | public function testXmlStringNotEqualsXmlFile() |
||
1138 | { |
||
1139 | $this->assertXmlStringNotEqualsXmlFile( |
||
1140 | $this->filesDirectory . 'foo.xml', |
||
1141 | file_get_contents($this->filesDirectory . 'bar.xml') |
||
1142 | ); |
||
1143 | |||
1144 | try { |
||
1145 | $this->assertXmlStringNotEqualsXmlFile( |
||
1146 | $this->filesDirectory . 'foo.xml', |
||
1147 | file_get_contents($this->filesDirectory . 'foo.xml') |
||
1148 | ); |
||
1149 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1150 | return; |
||
1151 | } |
||
1152 | |||
1153 | $this->fail(); |
||
1154 | } |
||
1155 | |||
1156 | /** |
||
1157 | * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString |
||
1158 | */ |
||
1159 | public function testAssertXmlStringEqualsXmlString() |
||
1160 | { |
||
1161 | $this->assertXmlStringEqualsXmlString('<root/>', '<root/>'); |
||
1162 | |||
1163 | try { |
||
1164 | $this->assertXmlStringEqualsXmlString('<foo/>', '<bar/>'); |
||
1165 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1166 | return; |
||
1167 | } |
||
1168 | |||
1169 | $this->fail(); |
||
1170 | } |
||
1171 | |||
1172 | /** |
||
1173 | * @expectedException PHPUnit_Framework_Exception |
||
1174 | * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString |
||
1175 | * @ticket 1860 |
||
1176 | */ |
||
1177 | public function testAssertXmlStringEqualsXmlString2() |
||
1178 | { |
||
1179 | $this->assertXmlStringEqualsXmlString('<a></b>', '<c></d>'); |
||
1180 | } |
||
1181 | |||
1182 | /** |
||
1183 | * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString |
||
1184 | * @ticket 1860 |
||
1185 | */ |
||
1186 | public function testAssertXmlStringEqualsXmlString3() |
||
1187 | { |
||
1188 | $expected = <<<XML |
||
1189 | <?xml version="1.0"?> |
||
1190 | <root> |
||
1191 | <node /> |
||
1192 | </root> |
||
1193 | XML; |
||
1194 | |||
1195 | $actual = <<<XML |
||
1196 | <?xml version="1.0"?> |
||
1197 | <root> |
||
1198 | <node /> |
||
1199 | </root> |
||
1200 | XML; |
||
1201 | |||
1202 | $this->assertXmlStringEqualsXmlString($expected, $actual); |
||
1203 | } |
||
1204 | |||
1205 | /** |
||
1206 | * @covers PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlString |
||
1207 | */ |
||
1208 | public function testAssertXmlStringNotEqualsXmlString() |
||
1209 | { |
||
1210 | $this->assertXmlStringNotEqualsXmlString('<foo/>', '<bar/>'); |
||
1211 | |||
1212 | try { |
||
1213 | $this->assertXmlStringNotEqualsXmlString('<root/>', '<root/>'); |
||
1214 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1215 | return; |
||
1216 | } |
||
1217 | |||
1218 | $this->fail(); |
||
1219 | } |
||
1220 | |||
1221 | /** |
||
1222 | * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure |
||
1223 | */ |
||
1224 | public function testXMLStructureIsSame() |
||
1225 | { |
||
1226 | $expected = new DOMDocument; |
||
1227 | $expected->load($this->filesDirectory . 'structureExpected.xml'); |
||
1228 | |||
1229 | $actual = new DOMDocument; |
||
1230 | $actual->load($this->filesDirectory . 'structureExpected.xml'); |
||
1231 | |||
1232 | $this->assertEqualXMLStructure( |
||
1233 | $expected->firstChild, $actual->firstChild, true |
||
1234 | ); |
||
1235 | } |
||
1236 | |||
1237 | /** |
||
1238 | * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure |
||
1239 | * @expectedException PHPUnit_Framework_ExpectationFailedException |
||
1240 | */ |
||
1241 | public function testXMLStructureWrongNumberOfAttributes() |
||
1242 | { |
||
1243 | $expected = new DOMDocument; |
||
1244 | $expected->load($this->filesDirectory . 'structureExpected.xml'); |
||
1245 | |||
1246 | $actual = new DOMDocument; |
||
1247 | $actual->load($this->filesDirectory . 'structureWrongNumberOfAttributes.xml'); |
||
1248 | |||
1249 | $this->assertEqualXMLStructure( |
||
1250 | $expected->firstChild, $actual->firstChild, true |
||
1251 | ); |
||
1252 | } |
||
1253 | |||
1254 | /** |
||
1255 | * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure |
||
1256 | * @expectedException PHPUnit_Framework_ExpectationFailedException |
||
1257 | */ |
||
1258 | public function testXMLStructureWrongNumberOfNodes() |
||
1259 | { |
||
1260 | $expected = new DOMDocument; |
||
1261 | $expected->load($this->filesDirectory . 'structureExpected.xml'); |
||
1262 | |||
1263 | $actual = new DOMDocument; |
||
1264 | $actual->load($this->filesDirectory . 'structureWrongNumberOfNodes.xml'); |
||
1265 | |||
1266 | $this->assertEqualXMLStructure( |
||
1267 | $expected->firstChild, $actual->firstChild, true |
||
1268 | ); |
||
1269 | } |
||
1270 | |||
1271 | /** |
||
1272 | * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure |
||
1273 | */ |
||
1274 | public function testXMLStructureIsSameButDataIsNot() |
||
1275 | { |
||
1276 | $expected = new DOMDocument; |
||
1277 | $expected->load($this->filesDirectory . 'structureExpected.xml'); |
||
1278 | |||
1279 | $actual = new DOMDocument; |
||
1280 | $actual->load($this->filesDirectory . 'structureIsSameButDataIsNot.xml'); |
||
1281 | |||
1282 | $this->assertEqualXMLStructure( |
||
1283 | $expected->firstChild, $actual->firstChild, true |
||
1284 | ); |
||
1285 | } |
||
1286 | |||
1287 | /** |
||
1288 | * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure |
||
1289 | */ |
||
1290 | public function testXMLStructureAttributesAreSameButValuesAreNot() |
||
1291 | { |
||
1292 | $expected = new DOMDocument; |
||
1293 | $expected->load($this->filesDirectory . 'structureExpected.xml'); |
||
1294 | |||
1295 | $actual = new DOMDocument; |
||
1296 | $actual->load($this->filesDirectory . 'structureAttributesAreSameButValuesAreNot.xml'); |
||
1297 | |||
1298 | $this->assertEqualXMLStructure( |
||
1299 | $expected->firstChild, $actual->firstChild, true |
||
1300 | ); |
||
1301 | } |
||
1302 | |||
1303 | /** |
||
1304 | * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure |
||
1305 | */ |
||
1306 | public function testXMLStructureIgnoreTextNodes() |
||
1307 | { |
||
1308 | $expected = new DOMDocument; |
||
1309 | $expected->load($this->filesDirectory . 'structureExpected.xml'); |
||
1310 | |||
1311 | $actual = new DOMDocument; |
||
1312 | $actual->load($this->filesDirectory . 'structureIgnoreTextNodes.xml'); |
||
1313 | |||
1314 | $this->assertEqualXMLStructure( |
||
1315 | $expected->firstChild, $actual->firstChild, true |
||
1316 | ); |
||
1317 | } |
||
1318 | |||
1319 | /** |
||
1320 | * @covers PHPUnit_Framework_Assert::assertEquals |
||
1321 | */ |
||
1322 | public function testAssertStringEqualsNumeric() |
||
1323 | { |
||
1324 | $this->assertEquals('0', 0); |
||
1325 | |||
1326 | try { |
||
1327 | $this->assertEquals('0', 1); |
||
1328 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1329 | return; |
||
1330 | } |
||
1331 | |||
1332 | $this->fail(); |
||
1333 | } |
||
1334 | |||
1335 | /** |
||
1336 | * @covers PHPUnit_Framework_Assert::assertNotEquals |
||
1337 | */ |
||
1338 | public function testAssertStringEqualsNumeric2() |
||
1339 | { |
||
1340 | $this->assertNotEquals('A', 0); |
||
1341 | } |
||
1342 | |||
1343 | /** |
||
1344 | * @covers PHPUnit_Framework_Assert::assertFileExists |
||
1345 | * @expectedException PHPUnit_Framework_Exception |
||
1346 | */ |
||
1347 | public function testAssertFileExistsThrowsException() |
||
1348 | { |
||
1349 | $this->assertFileExists(null); |
||
1350 | } |
||
1351 | |||
1352 | /** |
||
1353 | * @covers PHPUnit_Framework_Assert::assertFileExists |
||
1354 | */ |
||
1355 | public function testAssertFileExists() |
||
1356 | { |
||
1357 | $this->assertFileExists(__FILE__); |
||
1358 | |||
1359 | try { |
||
1360 | $this->assertFileExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
||
1361 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1362 | return; |
||
1363 | } |
||
1364 | |||
1365 | $this->fail(); |
||
1366 | } |
||
1367 | |||
1368 | /** |
||
1369 | * @covers PHPUnit_Framework_Assert::assertFileNotExists |
||
1370 | * @expectedException PHPUnit_Framework_Exception |
||
1371 | */ |
||
1372 | public function testAssertFileNotExistsThrowsException() |
||
1373 | { |
||
1374 | $this->assertFileNotExists(null); |
||
1375 | } |
||
1376 | |||
1377 | /** |
||
1378 | * @covers PHPUnit_Framework_Assert::assertFileNotExists |
||
1379 | */ |
||
1380 | public function testAssertFileNotExists() |
||
1381 | { |
||
1382 | $this->assertFileNotExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting'); |
||
1383 | |||
1384 | try { |
||
1385 | $this->assertFileNotExists(__FILE__); |
||
1386 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1387 | return; |
||
1388 | } |
||
1389 | |||
1390 | $this->fail(); |
||
1391 | } |
||
1392 | |||
1393 | /** |
||
1394 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
1395 | */ |
||
1396 | public function testAssertObjectHasAttribute() |
||
1397 | { |
||
1398 | $o = new Author('Terry Pratchett'); |
||
1399 | |||
1400 | $this->assertObjectHasAttribute('name', $o); |
||
1401 | |||
1402 | try { |
||
1403 | $this->assertObjectHasAttribute('foo', $o); |
||
1404 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1405 | return; |
||
1406 | } |
||
1407 | |||
1408 | $this->fail(); |
||
1409 | } |
||
1410 | |||
1411 | /** |
||
1412 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
1413 | */ |
||
1414 | public function testAssertObjectNotHasAttribute() |
||
1415 | { |
||
1416 | $o = new Author('Terry Pratchett'); |
||
1417 | |||
1418 | $this->assertObjectNotHasAttribute('foo', $o); |
||
1419 | |||
1420 | try { |
||
1421 | $this->assertObjectNotHasAttribute('name', $o); |
||
1422 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1423 | return; |
||
1424 | } |
||
1425 | |||
1426 | $this->fail(); |
||
1427 | } |
||
1428 | |||
1429 | /** |
||
1430 | * @covers PHPUnit_Framework_Assert::assertNull |
||
1431 | */ |
||
1432 | public function testAssertNull() |
||
1433 | { |
||
1434 | $this->assertNull(null); |
||
1435 | |||
1436 | try { |
||
1437 | $this->assertNull(new stdClass); |
||
1438 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1439 | return; |
||
1440 | } |
||
1441 | |||
1442 | $this->fail(); |
||
1443 | } |
||
1444 | |||
1445 | /** |
||
1446 | * @covers PHPUnit_Framework_Assert::assertNotNull |
||
1447 | */ |
||
1448 | public function testAssertNotNull() |
||
1449 | { |
||
1450 | $this->assertNotNull(new stdClass); |
||
1451 | |||
1452 | try { |
||
1453 | $this->assertNotNull(null); |
||
1454 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1455 | return; |
||
1456 | } |
||
1457 | |||
1458 | $this->fail(); |
||
1459 | } |
||
1460 | |||
1461 | /** |
||
1462 | * @covers PHPUnit_Framework_Assert::assertTrue |
||
1463 | */ |
||
1464 | public function testAssertTrue() |
||
1465 | { |
||
1466 | $this->assertTrue(true); |
||
1467 | |||
1468 | try { |
||
1469 | $this->assertTrue(false); |
||
1470 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1471 | return; |
||
1472 | } |
||
1473 | |||
1474 | $this->fail(); |
||
1475 | } |
||
1476 | |||
1477 | /** |
||
1478 | * @covers PHPUnit_Framework_Assert::assertNotTrue |
||
1479 | */ |
||
1480 | public function testAssertNotTrue() |
||
1481 | { |
||
1482 | $this->assertNotTrue(false); |
||
1483 | $this->assertNotTrue(1); |
||
1484 | $this->assertNotTrue('true'); |
||
1485 | |||
1486 | try { |
||
1487 | $this->assertNotTrue(true); |
||
1488 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1489 | return; |
||
1490 | } |
||
1491 | |||
1492 | $this->fail(); |
||
1493 | } |
||
1494 | |||
1495 | /** |
||
1496 | * @covers PHPUnit_Framework_Assert::assertFalse |
||
1497 | */ |
||
1498 | public function testAssertFalse() |
||
1499 | { |
||
1500 | $this->assertFalse(false); |
||
1501 | |||
1502 | try { |
||
1503 | $this->assertFalse(true); |
||
1504 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1505 | return; |
||
1506 | } |
||
1507 | |||
1508 | $this->fail(); |
||
1509 | } |
||
1510 | |||
1511 | /** |
||
1512 | * @covers PHPUnit_Framework_Assert::assertNotFalse |
||
1513 | */ |
||
1514 | public function testAssertNotFalse() |
||
1515 | { |
||
1516 | $this->assertNotFalse(true); |
||
1517 | $this->assertNotFalse(0); |
||
1518 | $this->assertNotFalse(''); |
||
1519 | |||
1520 | try { |
||
1521 | $this->assertNotFalse(false); |
||
1522 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1523 | return; |
||
1524 | } |
||
1525 | |||
1526 | $this->fail(); |
||
1527 | } |
||
1528 | |||
1529 | /** |
||
1530 | * @covers PHPUnit_Framework_Assert::assertRegExp |
||
1531 | * @expectedException PHPUnit_Framework_Exception |
||
1532 | */ |
||
1533 | public function testAssertRegExpThrowsException() |
||
1534 | { |
||
1535 | $this->assertRegExp(null, null); |
||
1536 | } |
||
1537 | |||
1538 | /** |
||
1539 | * @covers PHPUnit_Framework_Assert::assertRegExp |
||
1540 | * @expectedException PHPUnit_Framework_Exception |
||
1541 | */ |
||
1542 | public function testAssertRegExpThrowsException2() |
||
1543 | { |
||
1544 | $this->assertRegExp('', null); |
||
1545 | } |
||
1546 | |||
1547 | /** |
||
1548 | * @covers PHPUnit_Framework_Assert::assertNotRegExp |
||
1549 | * @expectedException PHPUnit_Framework_Exception |
||
1550 | */ |
||
1551 | public function testAssertNotRegExpThrowsException() |
||
1552 | { |
||
1553 | $this->assertNotRegExp(null, null); |
||
1554 | } |
||
1555 | |||
1556 | /** |
||
1557 | * @covers PHPUnit_Framework_Assert::assertNotRegExp |
||
1558 | * @expectedException PHPUnit_Framework_Exception |
||
1559 | */ |
||
1560 | public function testAssertNotRegExpThrowsException2() |
||
1561 | { |
||
1562 | $this->assertNotRegExp('', null); |
||
1563 | } |
||
1564 | |||
1565 | /** |
||
1566 | * @covers PHPUnit_Framework_Assert::assertRegExp |
||
1567 | */ |
||
1568 | public function testAssertRegExp() |
||
1569 | { |
||
1570 | $this->assertRegExp('/foo/', 'foobar'); |
||
1571 | |||
1572 | try { |
||
1573 | $this->assertRegExp('/foo/', 'bar'); |
||
1574 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1575 | return; |
||
1576 | } |
||
1577 | |||
1578 | $this->fail(); |
||
1579 | } |
||
1580 | |||
1581 | /** |
||
1582 | * @covers PHPUnit_Framework_Assert::assertNotRegExp |
||
1583 | */ |
||
1584 | public function testAssertNotRegExp() |
||
1585 | { |
||
1586 | $this->assertNotRegExp('/foo/', 'bar'); |
||
1587 | |||
1588 | try { |
||
1589 | $this->assertNotRegExp('/foo/', 'foobar'); |
||
1590 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1591 | return; |
||
1592 | } |
||
1593 | |||
1594 | $this->fail(); |
||
1595 | } |
||
1596 | |||
1597 | /** |
||
1598 | * @covers PHPUnit_Framework_Assert::assertSame |
||
1599 | */ |
||
1600 | public function testAssertSame() |
||
1601 | { |
||
1602 | $o = new stdClass; |
||
1603 | |||
1604 | $this->assertSame($o, $o); |
||
1605 | |||
1606 | try { |
||
1607 | $this->assertSame( |
||
1608 | new stdClass, |
||
1609 | new stdClass |
||
1610 | ); |
||
1611 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1612 | return; |
||
1613 | } |
||
1614 | |||
1615 | $this->fail(); |
||
1616 | } |
||
1617 | |||
1618 | /** |
||
1619 | * @covers PHPUnit_Framework_Assert::assertSame |
||
1620 | */ |
||
1621 | public function testAssertSame2() |
||
1622 | { |
||
1623 | $this->assertSame(true, true); |
||
1624 | $this->assertSame(false, false); |
||
1625 | |||
1626 | try { |
||
1627 | $this->assertSame(true, false); |
||
1628 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1629 | return; |
||
1630 | } |
||
1631 | |||
1632 | $this->fail(); |
||
1633 | } |
||
1634 | |||
1635 | /** |
||
1636 | * @covers PHPUnit_Framework_Assert::assertNotSame |
||
1637 | */ |
||
1638 | public function testAssertNotSame() |
||
1639 | { |
||
1640 | $this->assertNotSame( |
||
1641 | new stdClass, |
||
1642 | null |
||
1643 | ); |
||
1644 | |||
1645 | $this->assertNotSame( |
||
1646 | null, |
||
1647 | new stdClass |
||
1648 | ); |
||
1649 | |||
1650 | $this->assertNotSame( |
||
1651 | new stdClass, |
||
1652 | new stdClass |
||
1653 | ); |
||
1654 | |||
1655 | $o = new stdClass; |
||
1656 | |||
1657 | try { |
||
1658 | $this->assertNotSame($o, $o); |
||
1659 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1660 | return; |
||
1661 | } |
||
1662 | |||
1663 | $this->fail(); |
||
1664 | } |
||
1665 | |||
1666 | /** |
||
1667 | * @covers PHPUnit_Framework_Assert::assertNotSame |
||
1668 | */ |
||
1669 | public function testAssertNotSame2() |
||
1670 | { |
||
1671 | $this->assertNotSame(true, false); |
||
1672 | $this->assertNotSame(false, true); |
||
1673 | |||
1674 | try { |
||
1675 | $this->assertNotSame(true, true); |
||
1676 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1677 | return; |
||
1678 | } |
||
1679 | |||
1680 | $this->fail(); |
||
1681 | } |
||
1682 | |||
1683 | /** |
||
1684 | * @covers PHPUnit_Framework_Assert::assertNotSame |
||
1685 | */ |
||
1686 | public function testAssertNotSameFailsNull() |
||
1687 | { |
||
1688 | try { |
||
1689 | $this->assertNotSame(null, null); |
||
1690 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1691 | return; |
||
1692 | } |
||
1693 | |||
1694 | $this->fail(); |
||
1695 | } |
||
1696 | |||
1697 | /** |
||
1698 | * @covers PHPUnit_Framework_Assert::assertGreaterThan |
||
1699 | */ |
||
1700 | public function testGreaterThan() |
||
1701 | { |
||
1702 | $this->assertGreaterThan(1, 2); |
||
1703 | |||
1704 | try { |
||
1705 | $this->assertGreaterThan(2, 1); |
||
1706 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1707 | return; |
||
1708 | } |
||
1709 | |||
1710 | $this->fail(); |
||
1711 | } |
||
1712 | |||
1713 | /** |
||
1714 | * @covers PHPUnit_Framework_Assert::assertAttributeGreaterThan |
||
1715 | */ |
||
1716 | public function testAttributeGreaterThan() |
||
1717 | { |
||
1718 | $this->assertAttributeGreaterThan( |
||
1719 | 1, 'bar', new ClassWithNonPublicAttributes |
||
1720 | ); |
||
1721 | |||
1722 | try { |
||
1723 | $this->assertAttributeGreaterThan( |
||
1724 | 1, 'foo', new ClassWithNonPublicAttributes |
||
1725 | ); |
||
1726 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1727 | return; |
||
1728 | } |
||
1729 | |||
1730 | $this->fail(); |
||
1731 | } |
||
1732 | |||
1733 | /** |
||
1734 | * @covers PHPUnit_Framework_Assert::assertGreaterThanOrEqual |
||
1735 | */ |
||
1736 | public function testGreaterThanOrEqual() |
||
1737 | { |
||
1738 | $this->assertGreaterThanOrEqual(1, 2); |
||
1739 | |||
1740 | try { |
||
1741 | $this->assertGreaterThanOrEqual(2, 1); |
||
1742 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1743 | return; |
||
1744 | } |
||
1745 | |||
1746 | $this->fail(); |
||
1747 | } |
||
1748 | |||
1749 | /** |
||
1750 | * @covers PHPUnit_Framework_Assert::assertAttributeGreaterThanOrEqual |
||
1751 | */ |
||
1752 | public function testAttributeGreaterThanOrEqual() |
||
1753 | { |
||
1754 | $this->assertAttributeGreaterThanOrEqual( |
||
1755 | 1, 'bar', new ClassWithNonPublicAttributes |
||
1756 | ); |
||
1757 | |||
1758 | try { |
||
1759 | $this->assertAttributeGreaterThanOrEqual( |
||
1760 | 2, 'foo', new ClassWithNonPublicAttributes |
||
1761 | ); |
||
1762 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1763 | return; |
||
1764 | } |
||
1765 | |||
1766 | $this->fail(); |
||
1767 | } |
||
1768 | |||
1769 | /** |
||
1770 | * @covers PHPUnit_Framework_Assert::assertLessThan |
||
1771 | */ |
||
1772 | public function testLessThan() |
||
1773 | { |
||
1774 | $this->assertLessThan(2, 1); |
||
1775 | |||
1776 | try { |
||
1777 | $this->assertLessThan(1, 2); |
||
1778 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1779 | return; |
||
1780 | } |
||
1781 | |||
1782 | $this->fail(); |
||
1783 | } |
||
1784 | |||
1785 | /** |
||
1786 | * @covers PHPUnit_Framework_Assert::assertAttributeLessThan |
||
1787 | */ |
||
1788 | public function testAttributeLessThan() |
||
1789 | { |
||
1790 | $this->assertAttributeLessThan( |
||
1791 | 2, 'foo', new ClassWithNonPublicAttributes |
||
1792 | ); |
||
1793 | |||
1794 | try { |
||
1795 | $this->assertAttributeLessThan( |
||
1796 | 1, 'bar', new ClassWithNonPublicAttributes |
||
1797 | ); |
||
1798 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1799 | return; |
||
1800 | } |
||
1801 | |||
1802 | $this->fail(); |
||
1803 | } |
||
1804 | |||
1805 | /** |
||
1806 | * @covers PHPUnit_Framework_Assert::assertLessThanOrEqual |
||
1807 | */ |
||
1808 | public function testLessThanOrEqual() |
||
1809 | { |
||
1810 | $this->assertLessThanOrEqual(2, 1); |
||
1811 | |||
1812 | try { |
||
1813 | $this->assertLessThanOrEqual(1, 2); |
||
1814 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1815 | return; |
||
1816 | } |
||
1817 | |||
1818 | $this->fail(); |
||
1819 | } |
||
1820 | |||
1821 | /** |
||
1822 | * @covers PHPUnit_Framework_Assert::assertAttributeLessThanOrEqual |
||
1823 | */ |
||
1824 | public function testAttributeLessThanOrEqual() |
||
1825 | { |
||
1826 | $this->assertAttributeLessThanOrEqual( |
||
1827 | 2, 'foo', new ClassWithNonPublicAttributes |
||
1828 | ); |
||
1829 | |||
1830 | try { |
||
1831 | $this->assertAttributeLessThanOrEqual( |
||
1832 | 1, 'bar', new ClassWithNonPublicAttributes |
||
1833 | ); |
||
1834 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
1835 | return; |
||
1836 | } |
||
1837 | |||
1838 | $this->fail(); |
||
1839 | } |
||
1840 | |||
1841 | /** |
||
1842 | * @covers PHPUnit_Framework_Assert::readAttribute |
||
1843 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1844 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1845 | */ |
||
1846 | public function testReadAttribute() |
||
1847 | { |
||
1848 | $obj = new ClassWithNonPublicAttributes; |
||
1849 | |||
1850 | $this->assertEquals('foo', $this->readAttribute($obj, 'publicAttribute')); |
||
1851 | $this->assertEquals('bar', $this->readAttribute($obj, 'protectedAttribute')); |
||
1852 | $this->assertEquals('baz', $this->readAttribute($obj, 'privateAttribute')); |
||
1853 | $this->assertEquals('bar', $this->readAttribute($obj, 'protectedParentAttribute')); |
||
1854 | //$this->assertEquals('bar', $this->readAttribute($obj, 'privateParentAttribute')); |
||
1855 | } |
||
1856 | |||
1857 | /** |
||
1858 | * @covers PHPUnit_Framework_Assert::readAttribute |
||
1859 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1860 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1861 | */ |
||
1862 | public function testReadAttribute2() |
||
1863 | { |
||
1864 | $this->assertEquals('foo', $this->readAttribute('ClassWithNonPublicAttributes', 'publicStaticAttribute')); |
||
1865 | $this->assertEquals('bar', $this->readAttribute('ClassWithNonPublicAttributes', 'protectedStaticAttribute')); |
||
1866 | $this->assertEquals('baz', $this->readAttribute('ClassWithNonPublicAttributes', 'privateStaticAttribute')); |
||
1867 | $this->assertEquals('foo', $this->readAttribute('ClassWithNonPublicAttributes', 'protectedStaticParentAttribute')); |
||
1868 | $this->assertEquals('foo', $this->readAttribute('ClassWithNonPublicAttributes', 'privateStaticParentAttribute')); |
||
1869 | } |
||
1870 | |||
1871 | /** |
||
1872 | * @covers PHPUnit_Framework_Assert::readAttribute |
||
1873 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1874 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1875 | * @expectedException PHPUnit_Framework_Exception |
||
1876 | */ |
||
1877 | public function testReadAttribute3() |
||
1878 | { |
||
1879 | $this->readAttribute('StdClass', null); |
||
1880 | } |
||
1881 | |||
1882 | /** |
||
1883 | * @covers PHPUnit_Framework_Assert::readAttribute |
||
1884 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1885 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1886 | * @expectedException PHPUnit_Framework_Exception |
||
1887 | */ |
||
1888 | public function testReadAttribute4() |
||
1889 | { |
||
1890 | $this->readAttribute('NotExistingClass', 'foo'); |
||
1891 | } |
||
1892 | |||
1893 | /** |
||
1894 | * @covers PHPUnit_Framework_Assert::readAttribute |
||
1895 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1896 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1897 | * @expectedException PHPUnit_Framework_Exception |
||
1898 | */ |
||
1899 | public function testReadAttribute5() |
||
1900 | { |
||
1901 | $this->readAttribute(null, 'foo'); |
||
1902 | } |
||
1903 | |||
1904 | /** |
||
1905 | * @covers PHPUnit_Framework_Assert::readAttribute |
||
1906 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1907 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1908 | * @expectedException PHPUnit_Framework_Exception |
||
1909 | */ |
||
1910 | public function testReadAttributeIfAttributeNameIsNotValid() |
||
1911 | { |
||
1912 | $this->readAttribute('StdClass', '2'); |
||
1913 | } |
||
1914 | |||
1915 | /** |
||
1916 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1917 | * @expectedException PHPUnit_Framework_Exception |
||
1918 | */ |
||
1919 | public function testGetStaticAttributeRaisesExceptionForInvalidFirstArgument() |
||
1920 | { |
||
1921 | $this->getStaticAttribute(null, 'foo'); |
||
1922 | } |
||
1923 | |||
1924 | /** |
||
1925 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1926 | * @expectedException PHPUnit_Framework_Exception |
||
1927 | */ |
||
1928 | public function testGetStaticAttributeRaisesExceptionForInvalidFirstArgument2() |
||
1929 | { |
||
1930 | $this->getStaticAttribute('NotExistingClass', 'foo'); |
||
1931 | } |
||
1932 | |||
1933 | /** |
||
1934 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1935 | * @expectedException PHPUnit_Framework_Exception |
||
1936 | */ |
||
1937 | public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument() |
||
1938 | { |
||
1939 | $this->getStaticAttribute('stdClass', null); |
||
1940 | } |
||
1941 | |||
1942 | /** |
||
1943 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1944 | * @expectedException PHPUnit_Framework_Exception |
||
1945 | */ |
||
1946 | public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument2() |
||
1947 | { |
||
1948 | $this->getStaticAttribute('stdClass', '0'); |
||
1949 | } |
||
1950 | |||
1951 | /** |
||
1952 | * @covers PHPUnit_Framework_Assert::getStaticAttribute |
||
1953 | * @expectedException PHPUnit_Framework_Exception |
||
1954 | */ |
||
1955 | public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument3() |
||
1956 | { |
||
1957 | $this->getStaticAttribute('stdClass', 'foo'); |
||
1958 | } |
||
1959 | |||
1960 | /** |
||
1961 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1962 | * @expectedException PHPUnit_Framework_Exception |
||
1963 | */ |
||
1964 | public function testGetObjectAttributeRaisesExceptionForInvalidFirstArgument() |
||
1965 | { |
||
1966 | $this->getObjectAttribute(null, 'foo'); |
||
1967 | } |
||
1968 | |||
1969 | /** |
||
1970 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1971 | * @expectedException PHPUnit_Framework_Exception |
||
1972 | */ |
||
1973 | public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument() |
||
1974 | { |
||
1975 | $this->getObjectAttribute(new stdClass, null); |
||
1976 | } |
||
1977 | |||
1978 | /** |
||
1979 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1980 | * @expectedException PHPUnit_Framework_Exception |
||
1981 | */ |
||
1982 | public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument2() |
||
1983 | { |
||
1984 | $this->getObjectAttribute(new stdClass, '0'); |
||
1985 | } |
||
1986 | |||
1987 | /** |
||
1988 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1989 | * @expectedException PHPUnit_Framework_Exception |
||
1990 | */ |
||
1991 | public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument3() |
||
1992 | { |
||
1993 | $this->getObjectAttribute(new stdClass, 'foo'); |
||
1994 | } |
||
1995 | |||
1996 | /** |
||
1997 | * @covers PHPUnit_Framework_Assert::getObjectAttribute |
||
1998 | */ |
||
1999 | public function testGetObjectAttributeWorksForInheritedAttributes() |
||
2000 | { |
||
2001 | $this->assertEquals( |
||
2002 | 'bar', |
||
2003 | $this->getObjectAttribute(new ClassWithNonPublicAttributes, 'privateParentAttribute') |
||
2004 | ); |
||
2005 | } |
||
2006 | |||
2007 | /** |
||
2008 | * @covers PHPUnit_Framework_Assert::assertAttributeContains |
||
2009 | */ |
||
2010 | public function testAssertPublicAttributeContains() |
||
2011 | { |
||
2012 | $obj = new ClassWithNonPublicAttributes; |
||
2013 | |||
2014 | $this->assertAttributeContains('foo', 'publicArray', $obj); |
||
2015 | |||
2016 | try { |
||
2017 | $this->assertAttributeContains('bar', 'publicArray', $obj); |
||
2018 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2019 | return; |
||
2020 | } |
||
2021 | |||
2022 | $this->fail(); |
||
2023 | } |
||
2024 | |||
2025 | /** |
||
2026 | * @covers PHPUnit_Framework_Assert::assertAttributeContainsOnly |
||
2027 | */ |
||
2028 | public function testAssertPublicAttributeContainsOnly() |
||
2029 | { |
||
2030 | $obj = new ClassWithNonPublicAttributes; |
||
2031 | |||
2032 | $this->assertAttributeContainsOnly('string', 'publicArray', $obj); |
||
2033 | |||
2034 | try { |
||
2035 | $this->assertAttributeContainsOnly('integer', 'publicArray', $obj); |
||
2036 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2037 | return; |
||
2038 | } |
||
2039 | |||
2040 | $this->fail(); |
||
2041 | } |
||
2042 | |||
2043 | /** |
||
2044 | * @covers PHPUnit_Framework_Assert::assertAttributeNotContains |
||
2045 | */ |
||
2046 | public function testAssertPublicAttributeNotContains() |
||
2047 | { |
||
2048 | $obj = new ClassWithNonPublicAttributes; |
||
2049 | |||
2050 | $this->assertAttributeNotContains('bar', 'publicArray', $obj); |
||
2051 | |||
2052 | try { |
||
2053 | $this->assertAttributeNotContains('foo', 'publicArray', $obj); |
||
2054 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2055 | return; |
||
2056 | } |
||
2057 | |||
2058 | $this->fail(); |
||
2059 | } |
||
2060 | |||
2061 | /** |
||
2062 | * @covers PHPUnit_Framework_Assert::assertAttributeNotContainsOnly |
||
2063 | */ |
||
2064 | public function testAssertPublicAttributeNotContainsOnly() |
||
2065 | { |
||
2066 | $obj = new ClassWithNonPublicAttributes; |
||
2067 | |||
2068 | $this->assertAttributeNotContainsOnly('integer', 'publicArray', $obj); |
||
2069 | |||
2070 | try { |
||
2071 | $this->assertAttributeNotContainsOnly('string', 'publicArray', $obj); |
||
2072 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2073 | return; |
||
2074 | } |
||
2075 | |||
2076 | $this->fail(); |
||
2077 | } |
||
2078 | |||
2079 | /** |
||
2080 | * @covers PHPUnit_Framework_Assert::assertAttributeContains |
||
2081 | */ |
||
2082 | public function testAssertProtectedAttributeContains() |
||
2083 | { |
||
2084 | $obj = new ClassWithNonPublicAttributes; |
||
2085 | |||
2086 | $this->assertAttributeContains('bar', 'protectedArray', $obj); |
||
2087 | |||
2088 | try { |
||
2089 | $this->assertAttributeContains('foo', 'protectedArray', $obj); |
||
2090 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2091 | return; |
||
2092 | } |
||
2093 | |||
2094 | $this->fail(); |
||
2095 | } |
||
2096 | |||
2097 | /** |
||
2098 | * @covers PHPUnit_Framework_Assert::assertAttributeNotContains |
||
2099 | */ |
||
2100 | public function testAssertProtectedAttributeNotContains() |
||
2101 | { |
||
2102 | $obj = new ClassWithNonPublicAttributes; |
||
2103 | |||
2104 | $this->assertAttributeNotContains('foo', 'protectedArray', $obj); |
||
2105 | |||
2106 | try { |
||
2107 | $this->assertAttributeNotContains('bar', 'protectedArray', $obj); |
||
2108 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2109 | return; |
||
2110 | } |
||
2111 | |||
2112 | $this->fail(); |
||
2113 | } |
||
2114 | |||
2115 | /** |
||
2116 | * @covers PHPUnit_Framework_Assert::assertAttributeContains |
||
2117 | */ |
||
2118 | public function testAssertPrivateAttributeContains() |
||
2119 | { |
||
2120 | $obj = new ClassWithNonPublicAttributes; |
||
2121 | |||
2122 | $this->assertAttributeContains('baz', 'privateArray', $obj); |
||
2123 | |||
2124 | try { |
||
2125 | $this->assertAttributeContains('foo', 'privateArray', $obj); |
||
2126 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2127 | return; |
||
2128 | } |
||
2129 | |||
2130 | $this->fail(); |
||
2131 | } |
||
2132 | |||
2133 | /** |
||
2134 | * @covers PHPUnit_Framework_Assert::assertAttributeNotContains |
||
2135 | */ |
||
2136 | public function testAssertPrivateAttributeNotContains() |
||
2137 | { |
||
2138 | $obj = new ClassWithNonPublicAttributes; |
||
2139 | |||
2140 | $this->assertAttributeNotContains('foo', 'privateArray', $obj); |
||
2141 | |||
2142 | try { |
||
2143 | $this->assertAttributeNotContains('baz', 'privateArray', $obj); |
||
2144 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2145 | return; |
||
2146 | } |
||
2147 | |||
2148 | $this->fail(); |
||
2149 | } |
||
2150 | |||
2151 | /** |
||
2152 | * @covers PHPUnit_Framework_Assert::assertAttributeContains |
||
2153 | */ |
||
2154 | public function testAssertAttributeContainsNonObject() |
||
2155 | { |
||
2156 | $obj = new ClassWithNonPublicAttributes; |
||
2157 | |||
2158 | $this->assertAttributeContains(true, 'privateArray', $obj); |
||
2159 | |||
2160 | try { |
||
2161 | $this->assertAttributeContains(true, 'privateArray', $obj, '', false, true, true); |
||
2162 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2163 | return; |
||
2164 | } |
||
2165 | |||
2166 | $this->fail(); |
||
2167 | } |
||
2168 | |||
2169 | /** |
||
2170 | * @covers PHPUnit_Framework_Assert::assertAttributeNotContains |
||
2171 | */ |
||
2172 | public function testAssertAttributeNotContainsNonObject() |
||
2173 | { |
||
2174 | $obj = new ClassWithNonPublicAttributes; |
||
2175 | |||
2176 | $this->assertAttributeNotContains(true, 'privateArray', $obj, '', false, true, true); |
||
2177 | |||
2178 | try { |
||
2179 | $this->assertAttributeNotContains(true, 'privateArray', $obj); |
||
2180 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2181 | return; |
||
2182 | } |
||
2183 | |||
2184 | $this->fail(); |
||
2185 | } |
||
2186 | |||
2187 | /** |
||
2188 | * @covers PHPUnit_Framework_Assert::assertAttributeEquals |
||
2189 | */ |
||
2190 | public function testAssertPublicAttributeEquals() |
||
2191 | { |
||
2192 | $obj = new ClassWithNonPublicAttributes; |
||
2193 | |||
2194 | $this->assertAttributeEquals('foo', 'publicAttribute', $obj); |
||
2195 | |||
2196 | try { |
||
2197 | $this->assertAttributeEquals('bar', 'publicAttribute', $obj); |
||
2198 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2199 | return; |
||
2200 | } |
||
2201 | |||
2202 | $this->fail(); |
||
2203 | } |
||
2204 | |||
2205 | /** |
||
2206 | * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals |
||
2207 | */ |
||
2208 | public function testAssertPublicAttributeNotEquals() |
||
2209 | { |
||
2210 | $obj = new ClassWithNonPublicAttributes; |
||
2211 | |||
2212 | $this->assertAttributeNotEquals('bar', 'publicAttribute', $obj); |
||
2213 | |||
2214 | try { |
||
2215 | $this->assertAttributeNotEquals('foo', 'publicAttribute', $obj); |
||
2216 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2217 | return; |
||
2218 | } |
||
2219 | |||
2220 | $this->fail(); |
||
2221 | } |
||
2222 | |||
2223 | /** |
||
2224 | * @covers PHPUnit_Framework_Assert::assertAttributeSame |
||
2225 | */ |
||
2226 | public function testAssertPublicAttributeSame() |
||
2227 | { |
||
2228 | $obj = new ClassWithNonPublicAttributes; |
||
2229 | |||
2230 | $this->assertAttributeSame('foo', 'publicAttribute', $obj); |
||
2231 | |||
2232 | try { |
||
2233 | $this->assertAttributeSame('bar', 'publicAttribute', $obj); |
||
2234 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2235 | return; |
||
2236 | } |
||
2237 | |||
2238 | $this->fail(); |
||
2239 | } |
||
2240 | |||
2241 | /** |
||
2242 | * @covers PHPUnit_Framework_Assert::assertAttributeNotSame |
||
2243 | */ |
||
2244 | public function testAssertPublicAttributeNotSame() |
||
2245 | { |
||
2246 | $obj = new ClassWithNonPublicAttributes; |
||
2247 | |||
2248 | $this->assertAttributeNotSame('bar', 'publicAttribute', $obj); |
||
2249 | |||
2250 | try { |
||
2251 | $this->assertAttributeNotSame('foo', 'publicAttribute', $obj); |
||
2252 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2253 | return; |
||
2254 | } |
||
2255 | |||
2256 | $this->fail(); |
||
2257 | } |
||
2258 | |||
2259 | /** |
||
2260 | * @covers PHPUnit_Framework_Assert::assertAttributeEquals |
||
2261 | */ |
||
2262 | public function testAssertProtectedAttributeEquals() |
||
2263 | { |
||
2264 | $obj = new ClassWithNonPublicAttributes; |
||
2265 | |||
2266 | $this->assertAttributeEquals('bar', 'protectedAttribute', $obj); |
||
2267 | |||
2268 | try { |
||
2269 | $this->assertAttributeEquals('foo', 'protectedAttribute', $obj); |
||
2270 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2271 | return; |
||
2272 | } |
||
2273 | |||
2274 | $this->fail(); |
||
2275 | } |
||
2276 | |||
2277 | /** |
||
2278 | * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals |
||
2279 | */ |
||
2280 | public function testAssertProtectedAttributeNotEquals() |
||
2281 | { |
||
2282 | $obj = new ClassWithNonPublicAttributes; |
||
2283 | |||
2284 | $this->assertAttributeNotEquals('foo', 'protectedAttribute', $obj); |
||
2285 | |||
2286 | try { |
||
2287 | $this->assertAttributeNotEquals('bar', 'protectedAttribute', $obj); |
||
2288 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2289 | return; |
||
2290 | } |
||
2291 | |||
2292 | $this->fail(); |
||
2293 | } |
||
2294 | |||
2295 | /** |
||
2296 | * @covers PHPUnit_Framework_Assert::assertAttributeEquals |
||
2297 | */ |
||
2298 | public function testAssertPrivateAttributeEquals() |
||
2299 | { |
||
2300 | $obj = new ClassWithNonPublicAttributes; |
||
2301 | |||
2302 | $this->assertAttributeEquals('baz', 'privateAttribute', $obj); |
||
2303 | |||
2304 | try { |
||
2305 | $this->assertAttributeEquals('foo', 'privateAttribute', $obj); |
||
2306 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2307 | return; |
||
2308 | } |
||
2309 | |||
2310 | $this->fail(); |
||
2311 | } |
||
2312 | |||
2313 | /** |
||
2314 | * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals |
||
2315 | */ |
||
2316 | public function testAssertPrivateAttributeNotEquals() |
||
2317 | { |
||
2318 | $obj = new ClassWithNonPublicAttributes; |
||
2319 | |||
2320 | $this->assertAttributeNotEquals('foo', 'privateAttribute', $obj); |
||
2321 | |||
2322 | try { |
||
2323 | $this->assertAttributeNotEquals('baz', 'privateAttribute', $obj); |
||
2324 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2325 | return; |
||
2326 | } |
||
2327 | |||
2328 | $this->fail(); |
||
2329 | } |
||
2330 | |||
2331 | /** |
||
2332 | * @covers PHPUnit_Framework_Assert::assertAttributeEquals |
||
2333 | */ |
||
2334 | public function testAssertPublicStaticAttributeEquals() |
||
2335 | { |
||
2336 | $this->assertAttributeEquals('foo', 'publicStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2337 | |||
2338 | try { |
||
2339 | $this->assertAttributeEquals('bar', 'publicStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2340 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2341 | return; |
||
2342 | } |
||
2343 | |||
2344 | $this->fail(); |
||
2345 | } |
||
2346 | |||
2347 | /** |
||
2348 | * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals |
||
2349 | */ |
||
2350 | public function testAssertPublicStaticAttributeNotEquals() |
||
2351 | { |
||
2352 | $this->assertAttributeNotEquals('bar', 'publicStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2353 | |||
2354 | try { |
||
2355 | $this->assertAttributeNotEquals('foo', 'publicStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2356 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2357 | return; |
||
2358 | } |
||
2359 | |||
2360 | $this->fail(); |
||
2361 | } |
||
2362 | |||
2363 | /** |
||
2364 | * @covers PHPUnit_Framework_Assert::assertAttributeEquals |
||
2365 | */ |
||
2366 | public function testAssertProtectedStaticAttributeEquals() |
||
2367 | { |
||
2368 | $this->assertAttributeEquals('bar', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2369 | |||
2370 | try { |
||
2371 | $this->assertAttributeEquals('foo', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2372 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2373 | return; |
||
2374 | } |
||
2375 | |||
2376 | $this->fail(); |
||
2377 | } |
||
2378 | |||
2379 | /** |
||
2380 | * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals |
||
2381 | */ |
||
2382 | public function testAssertProtectedStaticAttributeNotEquals() |
||
2383 | { |
||
2384 | $this->assertAttributeNotEquals('foo', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2385 | |||
2386 | try { |
||
2387 | $this->assertAttributeNotEquals('bar', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2388 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2389 | return; |
||
2390 | } |
||
2391 | |||
2392 | $this->fail(); |
||
2393 | } |
||
2394 | |||
2395 | /** |
||
2396 | * @covers PHPUnit_Framework_Assert::assertAttributeEquals |
||
2397 | */ |
||
2398 | public function testAssertPrivateStaticAttributeEquals() |
||
2399 | { |
||
2400 | $this->assertAttributeEquals('baz', 'privateStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2401 | |||
2402 | try { |
||
2403 | $this->assertAttributeEquals('foo', 'privateStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2404 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2405 | return; |
||
2406 | } |
||
2407 | |||
2408 | $this->fail(); |
||
2409 | } |
||
2410 | |||
2411 | /** |
||
2412 | * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals |
||
2413 | */ |
||
2414 | public function testAssertPrivateStaticAttributeNotEquals() |
||
2415 | { |
||
2416 | $this->assertAttributeNotEquals('foo', 'privateStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2417 | |||
2418 | try { |
||
2419 | $this->assertAttributeNotEquals('baz', 'privateStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2420 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2421 | return; |
||
2422 | } |
||
2423 | |||
2424 | $this->fail(); |
||
2425 | } |
||
2426 | |||
2427 | /** |
||
2428 | * @covers PHPUnit_Framework_Assert::assertClassHasAttribute |
||
2429 | * @expectedException PHPUnit_Framework_Exception |
||
2430 | */ |
||
2431 | public function testAssertClassHasAttributeThrowsException() |
||
2432 | { |
||
2433 | $this->assertClassHasAttribute(null, null); |
||
2434 | } |
||
2435 | |||
2436 | /** |
||
2437 | * @covers PHPUnit_Framework_Assert::assertClassHasAttribute |
||
2438 | * @expectedException PHPUnit_Framework_Exception |
||
2439 | */ |
||
2440 | public function testAssertClassHasAttributeThrowsException2() |
||
2441 | { |
||
2442 | $this->assertClassHasAttribute('foo', null); |
||
2443 | } |
||
2444 | |||
2445 | /** |
||
2446 | * @covers PHPUnit_Framework_Assert::assertClassHasAttribute |
||
2447 | * @expectedException PHPUnit_Framework_Exception |
||
2448 | */ |
||
2449 | public function testAssertClassHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
||
2450 | { |
||
2451 | $this->assertClassHasAttribute('1', 'ClassWithNonPublicAttributes'); |
||
2452 | } |
||
2453 | |||
2454 | /** |
||
2455 | * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute |
||
2456 | * @expectedException PHPUnit_Framework_Exception |
||
2457 | */ |
||
2458 | public function testAssertClassNotHasAttributeThrowsException() |
||
2459 | { |
||
2460 | $this->assertClassNotHasAttribute(null, null); |
||
2461 | } |
||
2462 | |||
2463 | /** |
||
2464 | * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute |
||
2465 | * @expectedException PHPUnit_Framework_Exception |
||
2466 | */ |
||
2467 | public function testAssertClassNotHasAttributeThrowsException2() |
||
2468 | { |
||
2469 | $this->assertClassNotHasAttribute('foo', null); |
||
2470 | } |
||
2471 | |||
2472 | /** |
||
2473 | * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute |
||
2474 | * @expectedException PHPUnit_Framework_Exception |
||
2475 | */ |
||
2476 | public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
||
2477 | { |
||
2478 | $this->assertClassNotHasAttribute('1', 'ClassWithNonPublicAttributes'); |
||
2479 | } |
||
2480 | |||
2481 | /** |
||
2482 | * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute |
||
2483 | * @expectedException PHPUnit_Framework_Exception |
||
2484 | */ |
||
2485 | public function testAssertClassHasStaticAttributeThrowsException() |
||
2486 | { |
||
2487 | $this->assertClassHasStaticAttribute(null, null); |
||
2488 | } |
||
2489 | |||
2490 | /** |
||
2491 | * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute |
||
2492 | * @expectedException PHPUnit_Framework_Exception |
||
2493 | */ |
||
2494 | public function testAssertClassHasStaticAttributeThrowsException2() |
||
2495 | { |
||
2496 | $this->assertClassHasStaticAttribute('foo', null); |
||
2497 | } |
||
2498 | |||
2499 | /** |
||
2500 | * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute |
||
2501 | * @expectedException PHPUnit_Framework_Exception |
||
2502 | */ |
||
2503 | public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid() |
||
2504 | { |
||
2505 | $this->assertClassHasStaticAttribute('1', 'ClassWithNonPublicAttributes'); |
||
2506 | } |
||
2507 | |||
2508 | /** |
||
2509 | * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute |
||
2510 | * @expectedException PHPUnit_Framework_Exception |
||
2511 | */ |
||
2512 | public function testAssertClassNotHasStaticAttributeThrowsException() |
||
2513 | { |
||
2514 | $this->assertClassNotHasStaticAttribute(null, null); |
||
2515 | } |
||
2516 | |||
2517 | /** |
||
2518 | * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute |
||
2519 | * @expectedException PHPUnit_Framework_Exception |
||
2520 | */ |
||
2521 | public function testAssertClassNotHasStaticAttributeThrowsException2() |
||
2522 | { |
||
2523 | $this->assertClassNotHasStaticAttribute('foo', null); |
||
2524 | } |
||
2525 | |||
2526 | /** |
||
2527 | * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute |
||
2528 | * @expectedException PHPUnit_Framework_Exception |
||
2529 | */ |
||
2530 | public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid() |
||
2531 | { |
||
2532 | $this->assertClassNotHasStaticAttribute('1', 'ClassWithNonPublicAttributes'); |
||
2533 | } |
||
2534 | |||
2535 | /** |
||
2536 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
2537 | * @expectedException PHPUnit_Framework_Exception |
||
2538 | */ |
||
2539 | public function testAssertObjectHasAttributeThrowsException() |
||
2540 | { |
||
2541 | $this->assertObjectHasAttribute(null, null); |
||
2542 | } |
||
2543 | |||
2544 | /** |
||
2545 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
2546 | * @expectedException PHPUnit_Framework_Exception |
||
2547 | */ |
||
2548 | public function testAssertObjectHasAttributeThrowsException2() |
||
2549 | { |
||
2550 | $this->assertObjectHasAttribute('foo', null); |
||
2551 | } |
||
2552 | |||
2553 | /** |
||
2554 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
2555 | * @expectedException PHPUnit_Framework_Exception |
||
2556 | */ |
||
2557 | public function testAssertObjectHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
||
2558 | { |
||
2559 | $this->assertObjectHasAttribute('1', 'ClassWithNonPublicAttributes'); |
||
2560 | } |
||
2561 | |||
2562 | /** |
||
2563 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
2564 | * @expectedException PHPUnit_Framework_Exception |
||
2565 | */ |
||
2566 | public function testAssertObjectNotHasAttributeThrowsException() |
||
2567 | { |
||
2568 | $this->assertObjectNotHasAttribute(null, null); |
||
2569 | } |
||
2570 | |||
2571 | /** |
||
2572 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
2573 | * @expectedException PHPUnit_Framework_Exception |
||
2574 | */ |
||
2575 | public function testAssertObjectNotHasAttributeThrowsException2() |
||
2576 | { |
||
2577 | $this->assertObjectNotHasAttribute('foo', null); |
||
2578 | } |
||
2579 | |||
2580 | /** |
||
2581 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
2582 | * @expectedException PHPUnit_Framework_Exception |
||
2583 | */ |
||
2584 | public function testAssertObjectNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid() |
||
2585 | { |
||
2586 | $this->assertObjectNotHasAttribute('1', 'ClassWithNonPublicAttributes'); |
||
2587 | } |
||
2588 | |||
2589 | /** |
||
2590 | * @covers PHPUnit_Framework_Assert::assertClassHasAttribute |
||
2591 | */ |
||
2592 | public function testClassHasPublicAttribute() |
||
2593 | { |
||
2594 | $this->assertClassHasAttribute('publicAttribute', 'ClassWithNonPublicAttributes'); |
||
2595 | |||
2596 | try { |
||
2597 | $this->assertClassHasAttribute('attribute', 'ClassWithNonPublicAttributes'); |
||
2598 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2599 | return; |
||
2600 | } |
||
2601 | |||
2602 | $this->fail(); |
||
2603 | } |
||
2604 | |||
2605 | /** |
||
2606 | * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute |
||
2607 | */ |
||
2608 | public function testClassNotHasPublicAttribute() |
||
2609 | { |
||
2610 | $this->assertClassNotHasAttribute('attribute', 'ClassWithNonPublicAttributes'); |
||
2611 | |||
2612 | try { |
||
2613 | $this->assertClassNotHasAttribute('publicAttribute', 'ClassWithNonPublicAttributes'); |
||
2614 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2615 | return; |
||
2616 | } |
||
2617 | |||
2618 | $this->fail(); |
||
2619 | } |
||
2620 | |||
2621 | /** |
||
2622 | * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute |
||
2623 | */ |
||
2624 | public function testClassHasPublicStaticAttribute() |
||
2625 | { |
||
2626 | $this->assertClassHasStaticAttribute('publicStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2627 | |||
2628 | try { |
||
2629 | $this->assertClassHasStaticAttribute('attribute', 'ClassWithNonPublicAttributes'); |
||
2630 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2631 | return; |
||
2632 | } |
||
2633 | |||
2634 | $this->fail(); |
||
2635 | } |
||
2636 | |||
2637 | /** |
||
2638 | * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute |
||
2639 | */ |
||
2640 | public function testClassNotHasPublicStaticAttribute() |
||
2641 | { |
||
2642 | $this->assertClassNotHasStaticAttribute('attribute', 'ClassWithNonPublicAttributes'); |
||
2643 | |||
2644 | try { |
||
2645 | $this->assertClassNotHasStaticAttribute('publicStaticAttribute', 'ClassWithNonPublicAttributes'); |
||
2646 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2647 | return; |
||
2648 | } |
||
2649 | |||
2650 | $this->fail(); |
||
2651 | } |
||
2652 | |||
2653 | /** |
||
2654 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
2655 | */ |
||
2656 | public function testObjectHasPublicAttribute() |
||
2657 | { |
||
2658 | $obj = new ClassWithNonPublicAttributes; |
||
2659 | |||
2660 | $this->assertObjectHasAttribute('publicAttribute', $obj); |
||
2661 | |||
2662 | try { |
||
2663 | $this->assertObjectHasAttribute('attribute', $obj); |
||
2664 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2665 | return; |
||
2666 | } |
||
2667 | |||
2668 | $this->fail(); |
||
2669 | } |
||
2670 | |||
2671 | /** |
||
2672 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
2673 | */ |
||
2674 | public function testObjectNotHasPublicAttribute() |
||
2675 | { |
||
2676 | $obj = new ClassWithNonPublicAttributes; |
||
2677 | |||
2678 | $this->assertObjectNotHasAttribute('attribute', $obj); |
||
2679 | |||
2680 | try { |
||
2681 | $this->assertObjectNotHasAttribute('publicAttribute', $obj); |
||
2682 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2683 | return; |
||
2684 | } |
||
2685 | |||
2686 | $this->fail(); |
||
2687 | } |
||
2688 | |||
2689 | /** |
||
2690 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
2691 | */ |
||
2692 | public function testObjectHasOnTheFlyAttribute() |
||
2693 | { |
||
2694 | $obj = new stdClass; |
||
2695 | $obj->foo = 'bar'; |
||
2696 | |||
2697 | $this->assertObjectHasAttribute('foo', $obj); |
||
2698 | |||
2699 | try { |
||
2700 | $this->assertObjectHasAttribute('bar', $obj); |
||
2701 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2702 | return; |
||
2703 | } |
||
2704 | |||
2705 | $this->fail(); |
||
2706 | } |
||
2707 | |||
2708 | /** |
||
2709 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
2710 | */ |
||
2711 | public function testObjectNotHasOnTheFlyAttribute() |
||
2712 | { |
||
2713 | $obj = new stdClass; |
||
2714 | $obj->foo = 'bar'; |
||
2715 | |||
2716 | $this->assertObjectNotHasAttribute('bar', $obj); |
||
2717 | |||
2718 | try { |
||
2719 | $this->assertObjectNotHasAttribute('foo', $obj); |
||
2720 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2721 | return; |
||
2722 | } |
||
2723 | |||
2724 | $this->fail(); |
||
2725 | } |
||
2726 | |||
2727 | /** |
||
2728 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
2729 | */ |
||
2730 | public function testObjectHasProtectedAttribute() |
||
2731 | { |
||
2732 | $obj = new ClassWithNonPublicAttributes; |
||
2733 | |||
2734 | $this->assertObjectHasAttribute('protectedAttribute', $obj); |
||
2735 | |||
2736 | try { |
||
2737 | $this->assertObjectHasAttribute('attribute', $obj); |
||
2738 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2739 | return; |
||
2740 | } |
||
2741 | |||
2742 | $this->fail(); |
||
2743 | } |
||
2744 | |||
2745 | /** |
||
2746 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
2747 | */ |
||
2748 | public function testObjectNotHasProtectedAttribute() |
||
2749 | { |
||
2750 | $obj = new ClassWithNonPublicAttributes; |
||
2751 | |||
2752 | $this->assertObjectNotHasAttribute('attribute', $obj); |
||
2753 | |||
2754 | try { |
||
2755 | $this->assertObjectNotHasAttribute('protectedAttribute', $obj); |
||
2756 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2757 | return; |
||
2758 | } |
||
2759 | |||
2760 | $this->fail(); |
||
2761 | } |
||
2762 | |||
2763 | /** |
||
2764 | * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute |
||
2765 | */ |
||
2766 | public function testObjectHasPrivateAttribute() |
||
2767 | { |
||
2768 | $obj = new ClassWithNonPublicAttributes; |
||
2769 | |||
2770 | $this->assertObjectHasAttribute('privateAttribute', $obj); |
||
2771 | |||
2772 | try { |
||
2773 | $this->assertObjectHasAttribute('attribute', $obj); |
||
2774 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2775 | return; |
||
2776 | } |
||
2777 | |||
2778 | $this->fail(); |
||
2779 | } |
||
2780 | |||
2781 | /** |
||
2782 | * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute |
||
2783 | */ |
||
2784 | public function testObjectNotHasPrivateAttribute() |
||
2785 | { |
||
2786 | $obj = new ClassWithNonPublicAttributes; |
||
2787 | |||
2788 | $this->assertObjectNotHasAttribute('attribute', $obj); |
||
2789 | |||
2790 | try { |
||
2791 | $this->assertObjectNotHasAttribute('privateAttribute', $obj); |
||
2792 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
2793 | return; |
||
2794 | } |
||
2795 | |||
2796 | $this->fail(); |
||
2797 | } |
||
2798 | |||
2799 | /** |
||
2800 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2801 | * @covers PHPUnit_Framework_Assert::attribute |
||
2802 | * @covers PHPUnit_Framework_Assert::equalTo |
||
2803 | */ |
||
2804 | public function testAssertThatAttributeEquals() |
||
2805 | { |
||
2806 | $this->assertThat( |
||
2807 | new ClassWithNonPublicAttributes, |
||
2808 | $this->attribute( |
||
2809 | $this->equalTo('foo'), |
||
2810 | 'publicAttribute' |
||
2811 | ) |
||
2812 | ); |
||
2813 | } |
||
2814 | |||
2815 | /** |
||
2816 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2817 | * @covers PHPUnit_Framework_Assert::attribute |
||
2818 | * @covers PHPUnit_Framework_Assert::equalTo |
||
2819 | * @expectedException PHPUnit_Framework_AssertionFailedError |
||
2820 | */ |
||
2821 | public function testAssertThatAttributeEquals2() |
||
2822 | { |
||
2823 | $this->assertThat( |
||
2824 | new ClassWithNonPublicAttributes, |
||
2825 | $this->attribute( |
||
2826 | $this->equalTo('bar'), |
||
2827 | 'publicAttribute' |
||
2828 | ) |
||
2829 | ); |
||
2830 | } |
||
2831 | |||
2832 | /** |
||
2833 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2834 | * @covers PHPUnit_Framework_Assert::attribute |
||
2835 | * @covers PHPUnit_Framework_Assert::equalTo |
||
2836 | */ |
||
2837 | public function testAssertThatAttributeEqualTo() |
||
2838 | { |
||
2839 | $this->assertThat( |
||
2840 | new ClassWithNonPublicAttributes, |
||
2841 | $this->attributeEqualTo('publicAttribute', 'foo') |
||
2842 | ); |
||
2843 | } |
||
2844 | |||
2845 | /** |
||
2846 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2847 | * @covers PHPUnit_Framework_Assert::anything |
||
2848 | */ |
||
2849 | public function testAssertThatAnything() |
||
2850 | { |
||
2851 | $this->assertThat('anything', $this->anything()); |
||
2852 | } |
||
2853 | |||
2854 | /** |
||
2855 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2856 | * @covers PHPUnit_Framework_Assert::isTrue |
||
2857 | */ |
||
2858 | public function testAssertThatIsTrue() |
||
2859 | { |
||
2860 | $this->assertThat(true, $this->isTrue()); |
||
2861 | } |
||
2862 | |||
2863 | /** |
||
2864 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2865 | * @covers PHPUnit_Framework_Assert::isFalse |
||
2866 | */ |
||
2867 | public function testAssertThatIsFalse() |
||
2868 | { |
||
2869 | $this->assertThat(false, $this->isFalse()); |
||
2870 | } |
||
2871 | |||
2872 | /** |
||
2873 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2874 | * @covers PHPUnit_Framework_Assert::isJson |
||
2875 | */ |
||
2876 | public function testAssertThatIsJson() |
||
2877 | { |
||
2878 | $this->assertThat('{}', $this->isJson()); |
||
2879 | } |
||
2880 | |||
2881 | /** |
||
2882 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2883 | * @covers PHPUnit_Framework_Assert::anything |
||
2884 | * @covers PHPUnit_Framework_Assert::logicalAnd |
||
2885 | */ |
||
2886 | public function testAssertThatAnythingAndAnything() |
||
2887 | { |
||
2888 | $this->assertThat( |
||
2889 | 'anything', |
||
2890 | $this->logicalAnd( |
||
2891 | $this->anything(), $this->anything() |
||
2892 | ) |
||
2893 | ); |
||
2894 | } |
||
2895 | |||
2896 | /** |
||
2897 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2898 | * @covers PHPUnit_Framework_Assert::anything |
||
2899 | * @covers PHPUnit_Framework_Assert::logicalOr |
||
2900 | */ |
||
2901 | public function testAssertThatAnythingOrAnything() |
||
2902 | { |
||
2903 | $this->assertThat( |
||
2904 | 'anything', |
||
2905 | $this->logicalOr( |
||
2906 | $this->anything(), $this->anything() |
||
2907 | ) |
||
2908 | ); |
||
2909 | } |
||
2910 | |||
2911 | /** |
||
2912 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2913 | * @covers PHPUnit_Framework_Assert::anything |
||
2914 | * @covers PHPUnit_Framework_Assert::logicalNot |
||
2915 | * @covers PHPUnit_Framework_Assert::logicalXor |
||
2916 | */ |
||
2917 | public function testAssertThatAnythingXorNotAnything() |
||
2918 | { |
||
2919 | $this->assertThat( |
||
2920 | 'anything', |
||
2921 | $this->logicalXor( |
||
2922 | $this->anything(), |
||
2923 | $this->logicalNot($this->anything()) |
||
2924 | ) |
||
2925 | ); |
||
2926 | } |
||
2927 | |||
2928 | /** |
||
2929 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2930 | * @covers PHPUnit_Framework_Assert::contains |
||
2931 | */ |
||
2932 | public function testAssertThatContains() |
||
2933 | { |
||
2934 | $this->assertThat(array('foo'), $this->contains('foo')); |
||
2935 | } |
||
2936 | |||
2937 | /** |
||
2938 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2939 | * @covers PHPUnit_Framework_Assert::stringContains |
||
2940 | */ |
||
2941 | public function testAssertThatStringContains() |
||
2942 | { |
||
2943 | $this->assertThat('barfoobar', $this->stringContains('foo')); |
||
2944 | } |
||
2945 | |||
2946 | /** |
||
2947 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2948 | * @covers PHPUnit_Framework_Assert::containsOnly |
||
2949 | */ |
||
2950 | public function testAssertThatContainsOnly() |
||
2951 | { |
||
2952 | $this->assertThat(array('foo'), $this->containsOnly('string')); |
||
2953 | } |
||
2954 | /** |
||
2955 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2956 | * @covers PHPUnit_Framework_Assert::containsOnlyInstancesOf |
||
2957 | */ |
||
2958 | public function testAssertThatContainsOnlyInstancesOf() |
||
2959 | { |
||
2960 | $this->assertThat(array(new Book), $this->containsOnlyInstancesOf('Book')); |
||
2961 | } |
||
2962 | |||
2963 | /** |
||
2964 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2965 | * @covers PHPUnit_Framework_Assert::arrayHasKey |
||
2966 | */ |
||
2967 | public function testAssertThatArrayHasKey() |
||
2968 | { |
||
2969 | $this->assertThat(array('foo' => 'bar'), $this->arrayHasKey('foo')); |
||
2970 | } |
||
2971 | |||
2972 | /** |
||
2973 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2974 | * @covers PHPUnit_Framework_Assert::classHasAttribute |
||
2975 | */ |
||
2976 | public function testAssertThatClassHasAttribute() |
||
2977 | { |
||
2978 | $this->assertThat( |
||
2979 | new ClassWithNonPublicAttributes, |
||
2980 | $this->classHasAttribute('publicAttribute') |
||
2981 | ); |
||
2982 | } |
||
2983 | |||
2984 | /** |
||
2985 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2986 | * @covers PHPUnit_Framework_Assert::classHasStaticAttribute |
||
2987 | */ |
||
2988 | public function testAssertThatClassHasStaticAttribute() |
||
2989 | { |
||
2990 | $this->assertThat( |
||
2991 | new ClassWithNonPublicAttributes, |
||
2992 | $this->classHasStaticAttribute('publicStaticAttribute') |
||
2993 | ); |
||
2994 | } |
||
2995 | |||
2996 | /** |
||
2997 | * @covers PHPUnit_Framework_Assert::assertThat |
||
2998 | * @covers PHPUnit_Framework_Assert::objectHasAttribute |
||
2999 | */ |
||
3000 | public function testAssertThatObjectHasAttribute() |
||
3001 | { |
||
3002 | $this->assertThat( |
||
3003 | new ClassWithNonPublicAttributes, |
||
3004 | $this->objectHasAttribute('publicAttribute') |
||
3005 | ); |
||
3006 | } |
||
3007 | |||
3008 | /** |
||
3009 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3010 | * @covers PHPUnit_Framework_Assert::equalTo |
||
3011 | */ |
||
3012 | public function testAssertThatEqualTo() |
||
3013 | { |
||
3014 | $this->assertThat('foo', $this->equalTo('foo')); |
||
3015 | } |
||
3016 | |||
3017 | /** |
||
3018 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3019 | * @covers PHPUnit_Framework_Assert::identicalTo |
||
3020 | */ |
||
3021 | public function testAssertThatIdenticalTo() |
||
3022 | { |
||
3023 | $value = new stdClass; |
||
3024 | $constraint = $this->identicalTo($value); |
||
3025 | |||
3026 | $this->assertThat($value, $constraint); |
||
3027 | } |
||
3028 | |||
3029 | /** |
||
3030 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3031 | * @covers PHPUnit_Framework_Assert::isInstanceOf |
||
3032 | */ |
||
3033 | public function testAssertThatIsInstanceOf() |
||
3034 | { |
||
3035 | $this->assertThat(new stdClass, $this->isInstanceOf('StdClass')); |
||
3036 | } |
||
3037 | |||
3038 | /** |
||
3039 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3040 | * @covers PHPUnit_Framework_Assert::isType |
||
3041 | */ |
||
3042 | public function testAssertThatIsType() |
||
3043 | { |
||
3044 | $this->assertThat('string', $this->isType('string')); |
||
3045 | } |
||
3046 | |||
3047 | /** |
||
3048 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3049 | * @covers PHPUnit_Framework_Assert::isEmpty |
||
3050 | */ |
||
3051 | public function testAssertThatIsEmpty() |
||
3052 | { |
||
3053 | $this->assertThat(array(), $this->isEmpty()); |
||
3054 | } |
||
3055 | |||
3056 | /** |
||
3057 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3058 | * @covers PHPUnit_Framework_Assert::fileExists |
||
3059 | */ |
||
3060 | public function testAssertThatFileExists() |
||
3061 | { |
||
3062 | $this->assertThat(__FILE__, $this->fileExists()); |
||
3063 | } |
||
3064 | |||
3065 | /** |
||
3066 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3067 | * @covers PHPUnit_Framework_Assert::greaterThan |
||
3068 | */ |
||
3069 | public function testAssertThatGreaterThan() |
||
3070 | { |
||
3071 | $this->assertThat(2, $this->greaterThan(1)); |
||
3072 | } |
||
3073 | |||
3074 | /** |
||
3075 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3076 | * @covers PHPUnit_Framework_Assert::greaterThanOrEqual |
||
3077 | */ |
||
3078 | public function testAssertThatGreaterThanOrEqual() |
||
3079 | { |
||
3080 | $this->assertThat(2, $this->greaterThanOrEqual(1)); |
||
3081 | } |
||
3082 | |||
3083 | /** |
||
3084 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3085 | * @covers PHPUnit_Framework_Assert::lessThan |
||
3086 | */ |
||
3087 | public function testAssertThatLessThan() |
||
3088 | { |
||
3089 | $this->assertThat(1, $this->lessThan(2)); |
||
3090 | } |
||
3091 | |||
3092 | /** |
||
3093 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3094 | * @covers PHPUnit_Framework_Assert::lessThanOrEqual |
||
3095 | */ |
||
3096 | public function testAssertThatLessThanOrEqual() |
||
3097 | { |
||
3098 | $this->assertThat(1, $this->lessThanOrEqual(2)); |
||
3099 | } |
||
3100 | |||
3101 | /** |
||
3102 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3103 | * @covers PHPUnit_Framework_Assert::matchesRegularExpression |
||
3104 | */ |
||
3105 | public function testAssertThatMatchesRegularExpression() |
||
3106 | { |
||
3107 | $this->assertThat('foobar', $this->matchesRegularExpression('/foo/')); |
||
3108 | } |
||
3109 | |||
3110 | /** |
||
3111 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3112 | * @covers PHPUnit_Framework_Assert::callback |
||
3113 | */ |
||
3114 | public function testAssertThatCallback() |
||
3115 | { |
||
3116 | $this->assertThat( |
||
3117 | null, |
||
3118 | $this->callback(function ($other) { return true; }) |
||
3119 | ); |
||
3120 | } |
||
3121 | |||
3122 | /** |
||
3123 | * @covers PHPUnit_Framework_Assert::assertThat |
||
3124 | * @covers PHPUnit_Framework_Assert::countOf |
||
3125 | */ |
||
3126 | public function testAssertThatCountOf() |
||
3127 | { |
||
3128 | $this->assertThat(array(1), $this->countOf(1)); |
||
3129 | } |
||
3130 | |||
3131 | /** |
||
3132 | * @covers PHPUnit_Framework_Assert::assertFileEquals |
||
3133 | */ |
||
3134 | public function testAssertFileEquals() |
||
3135 | { |
||
3136 | $this->assertFileEquals( |
||
3137 | $this->filesDirectory . 'foo.xml', |
||
3138 | $this->filesDirectory . 'foo.xml' |
||
3139 | ); |
||
3140 | |||
3141 | try { |
||
3142 | $this->assertFileEquals( |
||
3143 | $this->filesDirectory . 'foo.xml', |
||
3144 | $this->filesDirectory . 'bar.xml' |
||
3145 | ); |
||
3146 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3147 | return; |
||
3148 | } |
||
3149 | |||
3150 | $this->fail(); |
||
3151 | } |
||
3152 | |||
3153 | /** |
||
3154 | * @covers PHPUnit_Framework_Assert::assertFileNotEquals |
||
3155 | */ |
||
3156 | public function testAssertFileNotEquals() |
||
3157 | { |
||
3158 | $this->assertFileNotEquals( |
||
3159 | $this->filesDirectory . 'foo.xml', |
||
3160 | $this->filesDirectory . 'bar.xml' |
||
3161 | ); |
||
3162 | |||
3163 | try { |
||
3164 | $this->assertFileNotEquals( |
||
3165 | $this->filesDirectory . 'foo.xml', |
||
3166 | $this->filesDirectory . 'foo.xml' |
||
3167 | ); |
||
3168 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3169 | return; |
||
3170 | } |
||
3171 | |||
3172 | $this->fail(); |
||
3173 | } |
||
3174 | |||
3175 | /** |
||
3176 | * @covers PHPUnit_Framework_Assert::assertStringEqualsFile |
||
3177 | */ |
||
3178 | public function testAssertStringEqualsFile() |
||
3179 | { |
||
3180 | $this->assertStringEqualsFile( |
||
3181 | $this->filesDirectory . 'foo.xml', |
||
3182 | file_get_contents($this->filesDirectory . 'foo.xml') |
||
3183 | ); |
||
3184 | |||
3185 | try { |
||
3186 | $this->assertStringEqualsFile( |
||
3187 | $this->filesDirectory . 'foo.xml', |
||
3188 | file_get_contents($this->filesDirectory . 'bar.xml') |
||
3189 | ); |
||
3190 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3191 | return; |
||
3192 | } |
||
3193 | |||
3194 | $this->fail(); |
||
3195 | } |
||
3196 | |||
3197 | /** |
||
3198 | * @covers PHPUnit_Framework_Assert::assertStringNotEqualsFile |
||
3199 | */ |
||
3200 | public function testAssertStringNotEqualsFile() |
||
3201 | { |
||
3202 | $this->assertStringNotEqualsFile( |
||
3203 | $this->filesDirectory . 'foo.xml', |
||
3204 | file_get_contents($this->filesDirectory . 'bar.xml') |
||
3205 | ); |
||
3206 | |||
3207 | try { |
||
3208 | $this->assertStringNotEqualsFile( |
||
3209 | $this->filesDirectory . 'foo.xml', |
||
3210 | file_get_contents($this->filesDirectory . 'foo.xml') |
||
3211 | ); |
||
3212 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3213 | return; |
||
3214 | } |
||
3215 | |||
3216 | $this->fail(); |
||
3217 | } |
||
3218 | |||
3219 | /** |
||
3220 | * @covers PHPUnit_Framework_Assert::assertStringStartsWith |
||
3221 | * @expectedException PHPUnit_Framework_Exception |
||
3222 | */ |
||
3223 | public function testAssertStringStartsWithThrowsException() |
||
3224 | { |
||
3225 | $this->assertStringStartsWith(null, null); |
||
3226 | } |
||
3227 | |||
3228 | /** |
||
3229 | * @covers PHPUnit_Framework_Assert::assertStringStartsWith |
||
3230 | * @expectedException PHPUnit_Framework_Exception |
||
3231 | */ |
||
3232 | public function testAssertStringStartsWithThrowsException2() |
||
3233 | { |
||
3234 | $this->assertStringStartsWith('', null); |
||
3235 | } |
||
3236 | |||
3237 | /** |
||
3238 | * @covers PHPUnit_Framework_Assert::assertStringStartsNotWith |
||
3239 | * @expectedException PHPUnit_Framework_Exception |
||
3240 | */ |
||
3241 | public function testAssertStringStartsNotWithThrowsException() |
||
3242 | { |
||
3243 | $this->assertStringStartsNotWith(null, null); |
||
3244 | } |
||
3245 | |||
3246 | /** |
||
3247 | * @covers PHPUnit_Framework_Assert::assertStringStartsNotWith |
||
3248 | * @expectedException PHPUnit_Framework_Exception |
||
3249 | */ |
||
3250 | public function testAssertStringStartsNotWithThrowsException2() |
||
3251 | { |
||
3252 | $this->assertStringStartsNotWith('', null); |
||
3253 | } |
||
3254 | |||
3255 | /** |
||
3256 | * @covers PHPUnit_Framework_Assert::assertStringEndsWith |
||
3257 | * @expectedException PHPUnit_Framework_Exception |
||
3258 | */ |
||
3259 | public function testAssertStringEndsWithThrowsException() |
||
3260 | { |
||
3261 | $this->assertStringEndsWith(null, null); |
||
3262 | } |
||
3263 | |||
3264 | /** |
||
3265 | * @covers PHPUnit_Framework_Assert::assertStringEndsWith |
||
3266 | * @expectedException PHPUnit_Framework_Exception |
||
3267 | */ |
||
3268 | public function testAssertStringEndsWithThrowsException2() |
||
3269 | { |
||
3270 | $this->assertStringEndsWith('', null); |
||
3271 | } |
||
3272 | |||
3273 | /** |
||
3274 | * @covers PHPUnit_Framework_Assert::assertStringEndsNotWith |
||
3275 | * @expectedException PHPUnit_Framework_Exception |
||
3276 | */ |
||
3277 | public function testAssertStringEndsNotWithThrowsException() |
||
3278 | { |
||
3279 | $this->assertStringEndsNotWith(null, null); |
||
3280 | } |
||
3281 | |||
3282 | /** |
||
3283 | * @covers PHPUnit_Framework_Assert::assertStringEndsNotWith |
||
3284 | * @expectedException PHPUnit_Framework_Exception |
||
3285 | */ |
||
3286 | public function testAssertStringEndsNotWithThrowsException2() |
||
3287 | { |
||
3288 | $this->assertStringEndsNotWith('', null); |
||
3289 | } |
||
3290 | |||
3291 | /** |
||
3292 | * @covers PHPUnit_Framework_Assert::assertStringStartsWith |
||
3293 | */ |
||
3294 | public function testAssertStringStartsWith() |
||
3295 | { |
||
3296 | $this->assertStringStartsWith('prefix', 'prefixfoo'); |
||
3297 | |||
3298 | try { |
||
3299 | $this->assertStringStartsWith('prefix', 'foo'); |
||
3300 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3301 | return; |
||
3302 | } |
||
3303 | |||
3304 | $this->fail(); |
||
3305 | } |
||
3306 | |||
3307 | /** |
||
3308 | * @covers PHPUnit_Framework_Assert::assertStringStartsNotWith |
||
3309 | */ |
||
3310 | public function testAssertStringStartsNotWith() |
||
3311 | { |
||
3312 | $this->assertStringStartsNotWith('prefix', 'foo'); |
||
3313 | |||
3314 | try { |
||
3315 | $this->assertStringStartsNotWith('prefix', 'prefixfoo'); |
||
3316 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3317 | return; |
||
3318 | } |
||
3319 | |||
3320 | $this->fail(); |
||
3321 | } |
||
3322 | |||
3323 | /** |
||
3324 | * @covers PHPUnit_Framework_Assert::assertStringEndsWith |
||
3325 | */ |
||
3326 | public function testAssertStringEndsWith() |
||
3327 | { |
||
3328 | $this->assertStringEndsWith('suffix', 'foosuffix'); |
||
3329 | |||
3330 | try { |
||
3331 | $this->assertStringEndsWith('suffix', 'foo'); |
||
3332 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3333 | return; |
||
3334 | } |
||
3335 | |||
3336 | $this->fail(); |
||
3337 | } |
||
3338 | |||
3339 | /** |
||
3340 | * @covers PHPUnit_Framework_Assert::assertStringEndsNotWith |
||
3341 | */ |
||
3342 | public function testAssertStringEndsNotWith() |
||
3343 | { |
||
3344 | $this->assertStringEndsNotWith('suffix', 'foo'); |
||
3345 | |||
3346 | try { |
||
3347 | $this->assertStringEndsNotWith('suffix', 'foosuffix'); |
||
3348 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3349 | return; |
||
3350 | } |
||
3351 | |||
3352 | $this->fail(); |
||
3353 | } |
||
3354 | |||
3355 | /** |
||
3356 | * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat |
||
3357 | * @expectedException PHPUnit_Framework_Exception |
||
3358 | */ |
||
3359 | public function testAssertStringMatchesFormatRaisesExceptionForInvalidFirstArgument() |
||
3360 | { |
||
3361 | $this->assertStringMatchesFormat(null, ''); |
||
3362 | } |
||
3363 | |||
3364 | /** |
||
3365 | * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat |
||
3366 | * @expectedException PHPUnit_Framework_Exception |
||
3367 | */ |
||
3368 | public function testAssertStringMatchesFormatRaisesExceptionForInvalidSecondArgument() |
||
3369 | { |
||
3370 | $this->assertStringMatchesFormat('', null); |
||
3371 | } |
||
3372 | |||
3373 | /** |
||
3374 | * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat |
||
3375 | */ |
||
3376 | public function testAssertStringMatchesFormat() |
||
3377 | { |
||
3378 | $this->assertStringMatchesFormat('*%s*', '***'); |
||
3379 | } |
||
3380 | |||
3381 | /** |
||
3382 | * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat |
||
3383 | * @expectedException PHPUnit_Framework_AssertionFailedError |
||
3384 | */ |
||
3385 | public function testAssertStringMatchesFormatFailure() |
||
3386 | { |
||
3387 | $this->assertStringMatchesFormat('*%s*', '**'); |
||
3388 | } |
||
3389 | |||
3390 | /** |
||
3391 | * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormat |
||
3392 | * @expectedException PHPUnit_Framework_Exception |
||
3393 | */ |
||
3394 | public function testAssertStringNotMatchesFormatRaisesExceptionForInvalidFirstArgument() |
||
3395 | { |
||
3396 | $this->assertStringNotMatchesFormat(null, ''); |
||
3397 | } |
||
3398 | |||
3399 | /** |
||
3400 | * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormat |
||
3401 | * @expectedException PHPUnit_Framework_Exception |
||
3402 | */ |
||
3403 | public function testAssertStringNotMatchesFormatRaisesExceptionForInvalidSecondArgument() |
||
3404 | { |
||
3405 | $this->assertStringNotMatchesFormat('', null); |
||
3406 | } |
||
3407 | |||
3408 | /** |
||
3409 | * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormat |
||
3410 | */ |
||
3411 | public function testAssertStringNotMatchesFormat() |
||
3412 | { |
||
3413 | $this->assertStringNotMatchesFormat('*%s*', '**'); |
||
3414 | |||
3415 | try { |
||
3416 | $this->assertStringMatchesFormat('*%s*', '**'); |
||
3417 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3418 | return; |
||
3419 | } |
||
3420 | |||
3421 | $this->fail(); |
||
3422 | } |
||
3423 | |||
3424 | /** |
||
3425 | * @covers PHPUnit_Framework_Assert::assertEmpty |
||
3426 | */ |
||
3427 | public function testAssertEmpty() |
||
3428 | { |
||
3429 | $this->assertEmpty(array()); |
||
3430 | |||
3431 | try { |
||
3432 | $this->assertEmpty(array('foo')); |
||
3433 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3434 | return; |
||
3435 | } |
||
3436 | |||
3437 | $this->fail(); |
||
3438 | } |
||
3439 | |||
3440 | /** |
||
3441 | * @covers PHPUnit_Framework_Assert::assertNotEmpty |
||
3442 | */ |
||
3443 | public function testAssertNotEmpty() |
||
3444 | { |
||
3445 | $this->assertNotEmpty(array('foo')); |
||
3446 | |||
3447 | try { |
||
3448 | $this->assertNotEmpty(array()); |
||
3449 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3450 | return; |
||
3451 | } |
||
3452 | |||
3453 | $this->fail(); |
||
3454 | } |
||
3455 | |||
3456 | /** |
||
3457 | * @covers PHPUnit_Framework_Assert::assertAttributeEmpty |
||
3458 | */ |
||
3459 | public function testAssertAttributeEmpty() |
||
3460 | { |
||
3461 | $o = new stdClass; |
||
3462 | $o->a = array(); |
||
3463 | |||
3464 | $this->assertAttributeEmpty('a', $o); |
||
3465 | |||
3466 | try { |
||
3467 | $o->a = array('b'); |
||
3468 | $this->assertAttributeEmpty('a', $o); |
||
3469 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3470 | return; |
||
3471 | } |
||
3472 | |||
3473 | $this->fail(); |
||
3474 | } |
||
3475 | |||
3476 | /** |
||
3477 | * @covers PHPUnit_Framework_Assert::assertAttributeNotEmpty |
||
3478 | */ |
||
3479 | public function testAssertAttributeNotEmpty() |
||
3480 | { |
||
3481 | $o = new stdClass; |
||
3482 | $o->a = array('b'); |
||
3483 | |||
3484 | $this->assertAttributeNotEmpty('a', $o); |
||
3485 | |||
3486 | try { |
||
3487 | $o->a = array(); |
||
3488 | $this->assertAttributeNotEmpty('a', $o); |
||
3489 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3490 | return; |
||
3491 | } |
||
3492 | |||
3493 | $this->fail(); |
||
3494 | } |
||
3495 | |||
3496 | /** |
||
3497 | * @covers PHPUnit_Framework_Assert::markTestIncomplete |
||
3498 | */ |
||
3499 | public function testMarkTestIncomplete() |
||
3500 | { |
||
3501 | try { |
||
3502 | $this->markTestIncomplete('incomplete'); |
||
3503 | } catch (PHPUnit_Framework_IncompleteTestError $e) { |
||
3504 | $this->assertEquals('incomplete', $e->getMessage()); |
||
3505 | |||
3506 | return; |
||
3507 | } |
||
3508 | |||
3509 | $this->fail(); |
||
3510 | } |
||
3511 | |||
3512 | /** |
||
3513 | * @covers PHPUnit_Framework_Assert::markTestSkipped |
||
3514 | */ |
||
3515 | public function testMarkTestSkipped() |
||
3516 | { |
||
3517 | try { |
||
3518 | $this->markTestSkipped('skipped'); |
||
3519 | } catch (PHPUnit_Framework_SkippedTestError $e) { |
||
3520 | $this->assertEquals('skipped', $e->getMessage()); |
||
3521 | |||
3522 | return; |
||
3523 | } |
||
3524 | |||
3525 | $this->fail(); |
||
3526 | } |
||
3527 | |||
3528 | /** |
||
3529 | * @covers PHPUnit_Framework_Assert::assertCount |
||
3530 | */ |
||
3531 | public function testAssertCount() |
||
3532 | { |
||
3533 | $this->assertCount(2, array(1, 2)); |
||
3534 | |||
3535 | try { |
||
3536 | $this->assertCount(2, array(1, 2, 3)); |
||
3537 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3538 | return; |
||
3539 | } |
||
3540 | |||
3541 | $this->fail(); |
||
3542 | } |
||
3543 | |||
3544 | /** |
||
3545 | * @covers PHPUnit_Framework_Assert::assertCount |
||
3546 | */ |
||
3547 | public function testAssertCountTraversable() |
||
3548 | { |
||
3549 | $this->assertCount(2, new ArrayIterator(array(1, 2))); |
||
3550 | |||
3551 | try { |
||
3552 | $this->assertCount(2, new ArrayIterator(array(1, 2, 3))); |
||
3553 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3554 | return; |
||
3555 | } |
||
3556 | |||
3557 | $this->fail(); |
||
3558 | } |
||
3559 | |||
3560 | /** |
||
3561 | * @covers PHPUnit_Framework_Assert::assertCount |
||
3562 | */ |
||
3563 | public function testAssertCountThrowsExceptionIfExpectedCountIsNoInteger() |
||
3564 | { |
||
3565 | try { |
||
3566 | $this->assertCount('a', array()); |
||
3567 | } catch (PHPUnit_Framework_Exception $e) { |
||
3568 | $this->assertEquals('Argument #1 (No Value) of PHPUnit_Framework_Assert::assertCount() must be a integer', $e->getMessage()); |
||
3569 | |||
3570 | return; |
||
3571 | } |
||
3572 | |||
3573 | $this->fail(); |
||
3574 | } |
||
3575 | |||
3576 | /** |
||
3577 | * @covers PHPUnit_Framework_Assert::assertCount |
||
3578 | */ |
||
3579 | public function testAssertCountThrowsExceptionIfElementIsNotCountable() |
||
3580 | { |
||
3581 | try { |
||
3582 | $this->assertCount(2, ''); |
||
3583 | } catch (PHPUnit_Framework_Exception $e) { |
||
3584 | $this->assertEquals('Argument #2 (No Value) of PHPUnit_Framework_Assert::assertCount() must be a countable or traversable', $e->getMessage()); |
||
3585 | |||
3586 | return; |
||
3587 | } |
||
3588 | |||
3589 | $this->fail(); |
||
3590 | } |
||
3591 | |||
3592 | /** |
||
3593 | * @covers PHPUnit_Framework_Assert::assertAttributeCount |
||
3594 | */ |
||
3595 | public function testAssertAttributeCount() |
||
3596 | { |
||
3597 | $o = new stdClass; |
||
3598 | $o->a = array(); |
||
3599 | |||
3600 | $this->assertAttributeCount(0, 'a', $o); |
||
3601 | } |
||
3602 | |||
3603 | /** |
||
3604 | * @covers PHPUnit_Framework_Assert::assertNotCount |
||
3605 | */ |
||
3606 | public function testAssertNotCount() |
||
3607 | { |
||
3608 | $this->assertNotCount(2, array(1, 2, 3)); |
||
3609 | |||
3610 | try { |
||
3611 | $this->assertNotCount(2, array(1, 2)); |
||
3612 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3613 | return; |
||
3614 | } |
||
3615 | |||
3616 | $this->fail(); |
||
3617 | } |
||
3618 | |||
3619 | /** |
||
3620 | * @covers PHPUnit_Framework_Assert::assertNotCount |
||
3621 | * @expectedException PHPUnit_Framework_Exception |
||
3622 | */ |
||
3623 | public function testAssertNotCountThrowsExceptionIfExpectedCountIsNoInteger() |
||
3624 | { |
||
3625 | $this->assertNotCount('a', array()); |
||
3626 | } |
||
3627 | |||
3628 | /** |
||
3629 | * @covers PHPUnit_Framework_Assert::assertNotCount |
||
3630 | * @expectedException PHPUnit_Framework_Exception |
||
3631 | */ |
||
3632 | public function testAssertNotCountThrowsExceptionIfElementIsNotCountable() |
||
3633 | { |
||
3634 | $this->assertNotCount(2, ''); |
||
3635 | } |
||
3636 | |||
3637 | /** |
||
3638 | * @covers PHPUnit_Framework_Assert::assertAttributeNotCount |
||
3639 | */ |
||
3640 | public function testAssertAttributeNotCount() |
||
3641 | { |
||
3642 | $o = new stdClass; |
||
3643 | $o->a = array(); |
||
3644 | |||
3645 | $this->assertAttributeNotCount(1, 'a', $o); |
||
3646 | } |
||
3647 | |||
3648 | /** |
||
3649 | * @covers PHPUnit_Framework_Assert::assertSameSize |
||
3650 | */ |
||
3651 | public function testAssertSameSize() |
||
3652 | { |
||
3653 | $this->assertSameSize(array(1, 2), array(3, 4)); |
||
3654 | |||
3655 | try { |
||
3656 | $this->assertSameSize(array(1, 2), array(1, 2, 3)); |
||
3657 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3658 | return; |
||
3659 | } |
||
3660 | |||
3661 | $this->fail(); |
||
3662 | } |
||
3663 | |||
3664 | /** |
||
3665 | * @covers PHPUnit_Framework_Assert::assertSameSize |
||
3666 | */ |
||
3667 | public function testAssertSameSizeThrowsExceptionIfExpectedIsNotCountable() |
||
3668 | { |
||
3669 | try { |
||
3670 | $this->assertSameSize('a', array()); |
||
3671 | } catch (PHPUnit_Framework_Exception $e) { |
||
3672 | $this->assertEquals('Argument #1 (No Value) of PHPUnit_Framework_Assert::assertSameSize() must be a countable or traversable', $e->getMessage()); |
||
3673 | |||
3674 | return; |
||
3675 | } |
||
3676 | |||
3677 | $this->fail(); |
||
3678 | } |
||
3679 | |||
3680 | /** |
||
3681 | * @covers PHPUnit_Framework_Assert::assertSameSize |
||
3682 | */ |
||
3683 | public function testAssertSameSizeThrowsExceptionIfActualIsNotCountable() |
||
3684 | { |
||
3685 | try { |
||
3686 | $this->assertSameSize(array(), ''); |
||
3687 | } catch (PHPUnit_Framework_Exception $e) { |
||
3688 | $this->assertEquals('Argument #2 (No Value) of PHPUnit_Framework_Assert::assertSameSize() must be a countable or traversable', $e->getMessage()); |
||
3689 | |||
3690 | return; |
||
3691 | } |
||
3692 | |||
3693 | $this->fail(); |
||
3694 | } |
||
3695 | |||
3696 | /** |
||
3697 | * @covers PHPUnit_Framework_Assert::assertNotSameSize |
||
3698 | */ |
||
3699 | public function testAssertNotSameSize() |
||
3700 | { |
||
3701 | $this->assertNotSameSize(array(1, 2), array(1, 2, 3)); |
||
3702 | |||
3703 | try { |
||
3704 | $this->assertNotSameSize(array(1, 2), array(3, 4)); |
||
3705 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3706 | return; |
||
3707 | } |
||
3708 | |||
3709 | $this->fail(); |
||
3710 | } |
||
3711 | |||
3712 | /** |
||
3713 | * @covers PHPUnit_Framework_Assert::assertNotSameSize |
||
3714 | * @expectedException PHPUnit_Framework_Exception |
||
3715 | */ |
||
3716 | public function testAssertNotSameSizeThrowsExceptionIfExpectedIsNotCountable() |
||
3717 | { |
||
3718 | $this->assertNotSameSize('a', array()); |
||
3719 | } |
||
3720 | |||
3721 | /** |
||
3722 | * @covers PHPUnit_Framework_Assert::assertNotSameSize |
||
3723 | * @expectedException PHPUnit_Framework_Exception |
||
3724 | */ |
||
3725 | public function testAssertNotSameSizeThrowsExceptionIfActualIsNotCountable() |
||
3726 | { |
||
3727 | $this->assertNotSameSize(array(), ''); |
||
3728 | } |
||
3729 | |||
3730 | /** |
||
3731 | * @covers PHPUnit_Framework_Assert::assertJson |
||
3732 | * @expectedException PHPUnit_Framework_Exception |
||
3733 | */ |
||
3734 | public function testAssertJsonRaisesExceptionForInvalidArgument() |
||
3735 | { |
||
3736 | $this->assertJson(null); |
||
3737 | } |
||
3738 | |||
3739 | /** |
||
3740 | * @covers PHPUnit_Framework_Assert::assertJson |
||
3741 | */ |
||
3742 | public function testAssertJson() |
||
3743 | { |
||
3744 | $this->assertJson('{}'); |
||
3745 | } |
||
3746 | |||
3747 | /** |
||
3748 | * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString |
||
3749 | */ |
||
3750 | public function testAssertJsonStringEqualsJsonString() |
||
3751 | { |
||
3752 | $expected = '{"Mascott" : "Tux"}'; |
||
3753 | $actual = '{"Mascott" : "Tux"}'; |
||
3754 | $message = 'Given Json strings do not match'; |
||
3755 | |||
3756 | $this->assertJsonStringEqualsJsonString($expected, $actual, $message); |
||
3757 | } |
||
3758 | |||
3759 | /** |
||
3760 | * @dataProvider validInvalidJsonDataprovider |
||
3761 | * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString |
||
3762 | */ |
||
3763 | public function testAssertJsonStringEqualsJsonStringErrorRaised($expected, $actual) |
||
3764 | { |
||
3765 | try { |
||
3766 | $this->assertJsonStringEqualsJsonString($expected, $actual); |
||
3767 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3768 | return; |
||
3769 | } |
||
3770 | $this->fail('Expected exception not found'); |
||
3771 | } |
||
3772 | |||
3773 | /** |
||
3774 | * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonString |
||
3775 | */ |
||
3776 | public function testAssertJsonStringNotEqualsJsonString() |
||
3777 | { |
||
3778 | $expected = '{"Mascott" : "Beastie"}'; |
||
3779 | $actual = '{"Mascott" : "Tux"}'; |
||
3780 | $message = 'Given Json strings do match'; |
||
3781 | |||
3782 | $this->assertJsonStringNotEqualsJsonString($expected, $actual, $message); |
||
3783 | } |
||
3784 | |||
3785 | /** |
||
3786 | * @dataProvider validInvalidJsonDataprovider |
||
3787 | * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonString |
||
3788 | */ |
||
3789 | public function testAssertJsonStringNotEqualsJsonStringErrorRaised($expected, $actual) |
||
3790 | { |
||
3791 | try { |
||
3792 | $this->assertJsonStringNotEqualsJsonString($expected, $actual); |
||
3793 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3794 | return; |
||
3795 | } |
||
3796 | $this->fail('Expected exception not found'); |
||
3797 | } |
||
3798 | |||
3799 | /** |
||
3800 | * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile |
||
3801 | */ |
||
3802 | public function testAssertJsonStringEqualsJsonFile() |
||
3803 | { |
||
3804 | $file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
||
3805 | $actual = json_encode(array('Mascott' => 'Tux')); |
||
3806 | $message = ''; |
||
3807 | $this->assertJsonStringEqualsJsonFile($file, $actual, $message); |
||
3808 | } |
||
3809 | |||
3810 | /** |
||
3811 | * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile |
||
3812 | */ |
||
3813 | public function testAssertJsonStringEqualsJsonFileExpectingExpectationFailedException() |
||
3814 | { |
||
3815 | $file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
||
3816 | $actual = json_encode(array('Mascott' => 'Beastie')); |
||
3817 | $message = ''; |
||
3818 | try { |
||
3819 | $this->assertJsonStringEqualsJsonFile($file, $actual, $message); |
||
3820 | } catch (PHPUnit_Framework_ExpectationFailedException $e) { |
||
3821 | $this->assertEquals( |
||
3822 | 'Failed asserting that \'{"Mascott":"Beastie"}\' matches JSON string "{"Mascott":"Tux"}".', |
||
3823 | $e->getMessage() |
||
3824 | ); |
||
3825 | |||
3826 | return; |
||
3827 | } |
||
3828 | |||
3829 | $this->fail('Expected Exception not thrown.'); |
||
3830 | } |
||
3831 | |||
3832 | /** |
||
3833 | * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile |
||
3834 | */ |
||
3835 | public function testAssertJsonStringEqualsJsonFileExpectingException() |
||
3836 | { |
||
3837 | $file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
||
3838 | try { |
||
3839 | $this->assertJsonStringEqualsJsonFile($file, null); |
||
3840 | } catch (PHPUnit_Framework_Exception $e) { |
||
3841 | return; |
||
3842 | } |
||
3843 | $this->fail('Expected Exception not thrown.'); |
||
3844 | } |
||
3845 | |||
3846 | /** |
||
3847 | * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonFile |
||
3848 | */ |
||
3849 | public function testAssertJsonStringNotEqualsJsonFile() |
||
3850 | { |
||
3851 | $file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
||
3852 | $actual = json_encode(array('Mascott' => 'Beastie')); |
||
3853 | $message = ''; |
||
3854 | $this->assertJsonStringNotEqualsJsonFile($file, $actual, $message); |
||
3855 | } |
||
3856 | |||
3857 | /** |
||
3858 | * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonFile |
||
3859 | */ |
||
3860 | public function testAssertJsonStringNotEqualsJsonFileExpectingException() |
||
3861 | { |
||
3862 | $file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
||
3863 | try { |
||
3864 | $this->assertJsonStringNotEqualsJsonFile($file, null); |
||
3865 | } catch (PHPUnit_Framework_Exception $e) { |
||
3866 | return; |
||
3867 | } |
||
3868 | $this->fail('Expected exception not found.'); |
||
3869 | } |
||
3870 | |||
3871 | /** |
||
3872 | * @covers PHPUnit_Framework_Assert::assertJsonFileNotEqualsJsonFile |
||
3873 | */ |
||
3874 | public function testAssertJsonFileNotEqualsJsonFile() |
||
3875 | { |
||
3876 | $fileExpected = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
||
3877 | $fileActual = __DIR__ . '/../_files/JsonData/arrayObject.json'; |
||
3878 | $message = ''; |
||
3879 | $this->assertJsonFileNotEqualsJsonFile($fileExpected, $fileActual, $message); |
||
3880 | } |
||
3881 | |||
3882 | /** |
||
3883 | * @covers PHPUnit_Framework_Assert::assertJsonFileEqualsJsonFile |
||
3884 | */ |
||
3885 | public function testAssertJsonFileEqualsJsonFile() |
||
3886 | { |
||
3887 | $file = __DIR__ . '/../_files/JsonData/simpleObject.json'; |
||
3888 | $message = ''; |
||
3889 | $this->assertJsonFileEqualsJsonFile($file, $file, $message); |
||
3890 | } |
||
3891 | |||
3892 | /** |
||
3893 | * @covers PHPUnit_Framework_Assert::assertInstanceOf |
||
3894 | */ |
||
3895 | public function testAssertInstanceOf() |
||
3896 | { |
||
3897 | $this->assertInstanceOf('stdClass', new stdClass); |
||
3898 | |||
3899 | try { |
||
3900 | $this->assertInstanceOf('Exception', new stdClass); |
||
3901 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3902 | return; |
||
3903 | } |
||
3904 | |||
3905 | $this->fail(); |
||
3906 | } |
||
3907 | |||
3908 | /** |
||
3909 | * @covers PHPUnit_Framework_Assert::assertInstanceOf |
||
3910 | * @expectedException PHPUnit_Framework_Exception |
||
3911 | */ |
||
3912 | public function testAssertInstanceOfThrowsExceptionForInvalidArgument() |
||
3913 | { |
||
3914 | $this->assertInstanceOf(null, new stdClass); |
||
3915 | } |
||
3916 | |||
3917 | /** |
||
3918 | * @covers PHPUnit_Framework_Assert::assertAttributeInstanceOf |
||
3919 | */ |
||
3920 | public function testAssertAttributeInstanceOf() |
||
3921 | { |
||
3922 | $o = new stdClass; |
||
3923 | $o->a = new stdClass; |
||
3924 | |||
3925 | $this->assertAttributeInstanceOf('stdClass', 'a', $o); |
||
3926 | } |
||
3927 | |||
3928 | /** |
||
3929 | * @covers PHPUnit_Framework_Assert::assertNotInstanceOf |
||
3930 | */ |
||
3931 | public function testAssertNotInstanceOf() |
||
3932 | { |
||
3933 | $this->assertNotInstanceOf('Exception', new stdClass); |
||
3934 | |||
3935 | try { |
||
3936 | $this->assertNotInstanceOf('stdClass', new stdClass); |
||
3937 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3938 | return; |
||
3939 | } |
||
3940 | |||
3941 | $this->fail(); |
||
3942 | } |
||
3943 | |||
3944 | /** |
||
3945 | * @covers PHPUnit_Framework_Assert::assertNotInstanceOf |
||
3946 | * @expectedException PHPUnit_Framework_Exception |
||
3947 | */ |
||
3948 | public function testAssertNotInstanceOfThrowsExceptionForInvalidArgument() |
||
3949 | { |
||
3950 | $this->assertNotInstanceOf(null, new stdClass); |
||
3951 | } |
||
3952 | |||
3953 | /** |
||
3954 | * @covers PHPUnit_Framework_Assert::assertAttributeNotInstanceOf |
||
3955 | */ |
||
3956 | public function testAssertAttributeNotInstanceOf() |
||
3957 | { |
||
3958 | $o = new stdClass; |
||
3959 | $o->a = new stdClass; |
||
3960 | |||
3961 | $this->assertAttributeNotInstanceOf('Exception', 'a', $o); |
||
3962 | } |
||
3963 | |||
3964 | /** |
||
3965 | * @covers PHPUnit_Framework_Assert::assertInternalType |
||
3966 | */ |
||
3967 | public function testAssertInternalType() |
||
3968 | { |
||
3969 | $this->assertInternalType('integer', 1); |
||
3970 | |||
3971 | try { |
||
3972 | $this->assertInternalType('string', 1); |
||
3973 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3974 | return; |
||
3975 | } |
||
3976 | |||
3977 | $this->fail(); |
||
3978 | } |
||
3979 | |||
3980 | /** |
||
3981 | * @covers PHPUnit_Framework_Assert::assertInternalType |
||
3982 | */ |
||
3983 | public function testAssertInternalTypeDouble() |
||
3984 | { |
||
3985 | $this->assertInternalType('double', 1.0); |
||
3986 | |||
3987 | try { |
||
3988 | $this->assertInternalType('double', 1); |
||
3989 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
3990 | return; |
||
3991 | } |
||
3992 | |||
3993 | $this->fail(); |
||
3994 | } |
||
3995 | |||
3996 | /** |
||
3997 | * @covers PHPUnit_Framework_Assert::assertInternalType |
||
3998 | * @expectedException PHPUnit_Framework_Exception |
||
3999 | */ |
||
4000 | public function testAssertInternalTypeThrowsExceptionForInvalidArgument() |
||
4001 | { |
||
4002 | $this->assertInternalType(null, 1); |
||
4003 | } |
||
4004 | |||
4005 | /** |
||
4006 | * @covers PHPUnit_Framework_Assert::assertAttributeInternalType |
||
4007 | */ |
||
4008 | public function testAssertAttributeInternalType() |
||
4009 | { |
||
4010 | $o = new stdClass; |
||
4011 | $o->a = 1; |
||
4012 | |||
4013 | $this->assertAttributeInternalType('integer', 'a', $o); |
||
4014 | } |
||
4015 | |||
4016 | /** |
||
4017 | * @covers PHPUnit_Framework_Assert::assertNotInternalType |
||
4018 | */ |
||
4019 | public function testAssertNotInternalType() |
||
4020 | { |
||
4021 | $this->assertNotInternalType('string', 1); |
||
4022 | |||
4023 | try { |
||
4024 | $this->assertNotInternalType('integer', 1); |
||
4025 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
4026 | return; |
||
4027 | } |
||
4028 | |||
4029 | $this->fail(); |
||
4030 | } |
||
4031 | |||
4032 | /** |
||
4033 | * @covers PHPUnit_Framework_Assert::assertNotInternalType |
||
4034 | * @expectedException PHPUnit_Framework_Exception |
||
4035 | */ |
||
4036 | public function testAssertNotInternalTypeThrowsExceptionForInvalidArgument() |
||
4037 | { |
||
4038 | $this->assertNotInternalType(null, 1); |
||
4039 | } |
||
4040 | |||
4041 | /** |
||
4042 | * @covers PHPUnit_Framework_Assert::assertAttributeNotInternalType |
||
4043 | */ |
||
4044 | public function testAssertAttributeNotInternalType() |
||
4045 | { |
||
4046 | $o = new stdClass; |
||
4047 | $o->a = 1; |
||
4048 | |||
4049 | $this->assertAttributeNotInternalType('string', 'a', $o); |
||
4050 | } |
||
4051 | |||
4052 | /** |
||
4053 | * @covers PHPUnit_Framework_Assert::assertStringMatchesFormatFile |
||
4054 | * @expectedException PHPUnit_Framework_Exception |
||
4055 | */ |
||
4056 | public function testAssertStringMatchesFormatFileThrowsExceptionForInvalidArgument() |
||
4057 | { |
||
4058 | $this->assertStringMatchesFormatFile('not_existing_file', ''); |
||
4059 | } |
||
4060 | |||
4061 | /** |
||
4062 | * @covers PHPUnit_Framework_Assert::assertStringMatchesFormatFile |
||
4063 | * @expectedException PHPUnit_Framework_Exception |
||
4064 | */ |
||
4065 | public function testAssertStringMatchesFormatFileThrowsExceptionForInvalidArgument2() |
||
4066 | { |
||
4067 | $this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', null); |
||
4068 | } |
||
4069 | |||
4070 | /** |
||
4071 | * @covers PHPUnit_Framework_Assert::assertStringMatchesFormatFile |
||
4072 | */ |
||
4073 | public function testAssertStringMatchesFormatFile() |
||
4074 | { |
||
4075 | $this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "FOO\n"); |
||
4076 | |||
4077 | try { |
||
4078 | $this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "BAR\n"); |
||
4079 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
4080 | return; |
||
4081 | } |
||
4082 | |||
4083 | $this->fail(); |
||
4084 | } |
||
4085 | |||
4086 | /** |
||
4087 | * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile |
||
4088 | * @expectedException PHPUnit_Framework_Exception |
||
4089 | */ |
||
4090 | public function testAssertStringNotMatchesFormatFileThrowsExceptionForInvalidArgument() |
||
4091 | { |
||
4092 | $this->assertStringNotMatchesFormatFile('not_existing_file', ''); |
||
4093 | } |
||
4094 | |||
4095 | /** |
||
4096 | * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile |
||
4097 | * @expectedException PHPUnit_Framework_Exception |
||
4098 | */ |
||
4099 | public function testAssertStringNotMatchesFormatFileThrowsExceptionForInvalidArgument2() |
||
4100 | { |
||
4101 | $this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', null); |
||
4102 | } |
||
4103 | |||
4104 | /** |
||
4105 | * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile |
||
4106 | */ |
||
4107 | public function testAssertStringNotMatchesFormatFile() |
||
4108 | { |
||
4109 | $this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "BAR\n"); |
||
4110 | |||
4111 | try { |
||
4112 | $this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "FOO\n"); |
||
4113 | } catch (PHPUnit_Framework_AssertionFailedError $e) { |
||
4114 | return; |
||
4115 | } |
||
4116 | |||
4117 | $this->fail(); |
||
4118 | } |
||
4119 | |||
4120 | /** |
||
4121 | * @return array |
||
4122 | */ |
||
4123 | public static function validInvalidJsonDataprovider() |
||
4124 | { |
||
4125 | return array( |
||
4126 | 'error syntax in expected JSON' => array('{"Mascott"::}', '{"Mascott" : "Tux"}'), |
||
4127 | 'error UTF-8 in actual JSON' => array('{"Mascott" : "Tux"}', '{"Mascott" : :}'), |
||
4128 | ); |
||
4129 | } |
||
4130 | } |
||
4131 |