]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/PHPUnit/Tests/Framework/TestFailureTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / PHPUnit / Tests / Framework / TestFailureTest.php
1 <?php
2 /**
3  * PHPUnit
4  *
5  * Copyright (c) 2002-2009, Sebastian Bergmann <sb@sebastian-bergmann.de>.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  *   * Redistributions of source code must retain the above copyright
13  *     notice, this list of conditions and the following disclaimer.
14  *
15  *   * Redistributions in binary form must reproduce the above copyright
16  *     notice, this list of conditions and the following disclaimer in
17  *     the documentation and/or other materials provided with the
18  *     distribution.
19  *
20  *   * Neither the name of Sebastian Bergmann nor the names of his
21  *     contributors may be used to endorse or promote products derived
22  *     from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * @category   Testing
38  * @package    PHPUnit
39  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
40  * @copyright  2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
41  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
42
43  * @link       http://www.phpunit.de/
44  * @since      File available since Release 3.3.0
45  */
46
47 require_once 'PHPUnit/Framework/TestCase.php';
48
49 require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ClassWithNonPublicAttributes.php';
50
51 /**
52  *
53  *
54  * @category   Testing
55  * @package    PHPUnit
56  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
57  * @copyright  2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
58  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
59  * @version    Release: 3.3.17
60  * @link       http://www.phpunit.de/
61  * @since      Class available since Release 3.3.0
62  */
63 class Framework_TestFailureTest extends PHPUnit_Framework_TestCase
64 {
65     public function testFailureArrayHasKey()
66     {
67         $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey(0);
68
69         try {
70             $constraint->fail(array(), '');
71         }
72
73         catch (PHPUnit_Framework_ExpectationFailedException $e) {
74             $this->assertEquals(
75               "Failed asserting that an array has the key <integer:0>.\n",
76               PHPUnit_Framework_TestFailure::exceptionToString($e)
77             );
78
79             return;
80         }
81
82         $this->fail();
83     }
84
85     public function testFailureArrayHasKey2()
86     {
87         $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey(0);
88
89         try {
90             $constraint->fail(array(), 'custom message');
91         }
92
93         catch (PHPUnit_Framework_ExpectationFailedException $e) {
94             $this->assertEquals(
95               "custom message\nFailed asserting that an array has the key <integer:0>.\n",
96               PHPUnit_Framework_TestFailure::exceptionToString($e)
97             );
98
99             return;
100         }
101
102         $this->fail();
103     }
104
105     public function testFailureArrayNotHasKey()
106     {
107         $constraint = new PHPUnit_Framework_Constraint_Not(
108           new PHPUnit_Framework_Constraint_ArrayHasKey(0)
109         );
110
111         try {
112             $constraint->fail(array(0), '', TRUE);
113         }
114
115         catch (PHPUnit_Framework_ExpectationFailedException $e) {
116             $this->assertEquals(
117               "Failed asserting that an array does not have the key <integer:0>.\n",
118               PHPUnit_Framework_TestFailure::exceptionToString($e)
119             );
120
121             return;
122         }
123
124         $this->fail();
125     }
126
127     public function testFailureArrayNotHasKey2()
128     {
129         $constraint = new PHPUnit_Framework_Constraint_Not(
130           new PHPUnit_Framework_Constraint_ArrayHasKey(0)
131         );
132
133         try {
134             $constraint->fail(array(0), 'custom message', TRUE);
135         }
136
137         catch (PHPUnit_Framework_ExpectationFailedException $e) {
138             $this->assertEquals(
139               "custom message\nFailed asserting that an array does not have the key <integer:0>.\n",
140               PHPUnit_Framework_TestFailure::exceptionToString($e)
141             );
142
143             return;
144         }
145
146         $this->fail();
147     }
148
149     public function testFailureFileExists()
150     {
151         $constraint = new PHPUnit_Framework_Constraint_FileExists;
152
153         try {
154             $constraint->fail('foo', '');
155         }
156
157         catch (PHPUnit_Framework_ExpectationFailedException $e) {
158             $this->assertEquals(
159               "Failed asserting that file \"foo\" exists.\n",
160               PHPUnit_Framework_TestFailure::exceptionToString($e)
161             );
162
163             return;
164         }
165
166         $this->fail();
167     }
168
169     public function testFailureFileExists2()
170     {
171         $constraint = new PHPUnit_Framework_Constraint_FileExists;
172
173         try {
174             $constraint->fail('foo', 'custom message');
175         }
176
177         catch (PHPUnit_Framework_ExpectationFailedException $e) {
178             $this->assertEquals(
179               "custom message\nFailed asserting that file \"foo\" exists.\n",
180               PHPUnit_Framework_TestFailure::exceptionToString($e)
181             );
182
183             return;
184         }
185
186         $this->fail();
187     }
188
189     public function testFailureFileNotExists()
190     {
191         $constraint = new PHPUnit_Framework_Constraint_Not(
192           new PHPUnit_Framework_Constraint_FileExists
193         );
194
195         try {
196             $constraint->fail('foo', '', TRUE);
197         }
198
199         catch (PHPUnit_Framework_ExpectationFailedException $e) {
200             $this->assertEquals(
201               "Failed asserting that file \"foo\" does not exist.\n",
202               PHPUnit_Framework_TestFailure::exceptionToString($e)
203             );
204
205             return;
206         }
207
208         $this->fail();
209     }
210
211     public function testFailureFileNotExists2()
212     {
213         $constraint = new PHPUnit_Framework_Constraint_Not(
214           new PHPUnit_Framework_Constraint_FileExists
215         );
216
217         try {
218             $constraint->fail('foo', 'custom message', TRUE);
219         }
220
221         catch (PHPUnit_Framework_ExpectationFailedException $e) {
222             $this->assertEquals(
223               "custom message\nFailed asserting that file \"foo\" does not exist.\n",
224               PHPUnit_Framework_TestFailure::exceptionToString($e)
225             );
226
227             return;
228         }
229
230         $this->fail();
231     }
232
233     public function testFailureGreaterThan()
234     {
235         $constraint = new PHPUnit_Framework_Constraint_GreaterThan(1);
236
237         try {
238             $constraint->fail(0, '');
239         }
240
241         catch (PHPUnit_Framework_ExpectationFailedException $e) {
242             $this->assertEquals(
243               "Failed asserting that <integer:0> is greater than <integer:1>.\n",
244               PHPUnit_Framework_TestFailure::exceptionToString($e)
245             );
246
247             return;
248         }
249
250         $this->fail();
251     }
252
253     public function testFailureGreaterThan2()
254     {
255         $constraint = new PHPUnit_Framework_Constraint_GreaterThan(1);
256
257         try {
258             $constraint->fail(0, 'custom message');
259         }
260
261         catch (PHPUnit_Framework_ExpectationFailedException $e) {
262             $this->assertEquals(
263               "custom message\nFailed asserting that <integer:0> is greater than <integer:1>.\n",
264               PHPUnit_Framework_TestFailure::exceptionToString($e)
265             );
266
267             return;
268         }
269
270         $this->fail();
271     }
272
273     public function testFailureNotGreaterThan()
274     {
275         $constraint = new PHPUnit_Framework_Constraint_Not(
276           new PHPUnit_Framework_Constraint_GreaterThan(1)
277         );
278
279         try {
280             $constraint->fail(1, '', TRUE);
281         }
282
283         catch (PHPUnit_Framework_ExpectationFailedException $e) {
284             $this->assertEquals(
285               "Failed asserting that <integer:1> is not greater than <integer:1>.\n",
286               PHPUnit_Framework_TestFailure::exceptionToString($e)
287             );
288
289             return;
290         }
291
292         $this->fail();
293     }
294
295     public function testFailureNotGreaterThan2()
296     {
297         $constraint = new PHPUnit_Framework_Constraint_Not(
298           new PHPUnit_Framework_Constraint_GreaterThan(1)
299         );
300
301         try {
302             $constraint->fail(1, 'custom message', TRUE);
303         }
304
305         catch (PHPUnit_Framework_ExpectationFailedException $e) {
306             $this->assertEquals(
307               "custom message\nFailed asserting that <integer:1> is not greater than <integer:1>.\n",
308               PHPUnit_Framework_TestFailure::exceptionToString($e)
309             );
310
311             return;
312         }
313
314         $this->fail();
315     }
316
317     public function testFailureIsEqual()
318     {
319         $constraint = new PHPUnit_Framework_Constraint_IsEqual(1);
320
321         try {
322             $constraint->fail(0, '');
323         }
324
325         catch (PHPUnit_Framework_ExpectationFailedException $e) {
326             $this->assertEquals(
327               "Failed asserting that <integer:0> matches expected value <integer:1>.\n",
328               PHPUnit_Framework_TestFailure::exceptionToString($e)
329             );
330
331             return;
332         }
333
334         $this->fail();
335     }
336
337     public function testFailureIsEqual2()
338     {
339         $constraint = new PHPUnit_Framework_Constraint_IsEqual(1);
340
341         try {
342             $constraint->fail(0, 'custom message');
343         }
344
345         catch (PHPUnit_Framework_ExpectationFailedException $e) {
346             $this->assertEquals(
347               "custom message\nFailed asserting that <integer:0> matches expected value <integer:1>.\n",
348               PHPUnit_Framework_TestFailure::exceptionToString($e)
349             );
350
351             return;
352         }
353
354         $this->fail();
355     }
356
357     public function testFailureIsNotEqual()
358     {
359         $constraint = new PHPUnit_Framework_Constraint_Not(
360           new PHPUnit_Framework_Constraint_IsEqual(1)
361         );
362
363         try {
364             $constraint->fail(1, '', TRUE);
365         }
366
367         catch (PHPUnit_Framework_ExpectationFailedException $e) {
368             $this->assertEquals(
369               "Failed asserting that <integer:1> is not equal to <integer:1>.\n",
370               PHPUnit_Framework_TestFailure::exceptionToString($e)
371             );
372
373             return;
374         }
375
376         $this->fail();
377     }
378
379     public function testFailureIsNotEqual2()
380     {
381         $constraint = new PHPUnit_Framework_Constraint_Not(
382           new PHPUnit_Framework_Constraint_IsEqual(1)
383         );
384
385         try {
386             $constraint->fail(1, 'custom message', TRUE);
387         }
388
389         catch (PHPUnit_Framework_ExpectationFailedException $e) {
390             $this->assertEquals(
391               "custom message\nFailed asserting that <integer:1> is not equal to <integer:1>.\n",
392               PHPUnit_Framework_TestFailure::exceptionToString($e)
393             );
394
395             return;
396         }
397
398         $this->fail();
399     }
400
401     public function testFailureIsIdentical()
402     {
403         $a = new stdClass;
404         $b = new stdClass;
405
406         $constraint = new PHPUnit_Framework_Constraint_IsIdentical($a);
407
408         try {
409             $constraint->fail($b, '');
410         }
411
412         catch (PHPUnit_Framework_ExpectationFailedException $e) {
413             $this->assertEquals(
414               "Failed asserting that two variables reference the same object.\n",
415               PHPUnit_Framework_TestFailure::exceptionToString($e)
416             );
417
418             return;
419         }
420
421         $this->fail();
422     }
423
424     public function testFailureIsIdentical2()
425     {
426         $a = new stdClass;
427         $b = new stdClass;
428
429         $constraint = new PHPUnit_Framework_Constraint_IsIdentical($a);
430
431         try {
432             $constraint->fail($b, 'custom message');
433         }
434
435         catch (PHPUnit_Framework_ExpectationFailedException $e) {
436             $this->assertEquals(
437               "custom message\nFailed asserting that two variables reference the same object.\n",
438               PHPUnit_Framework_TestFailure::exceptionToString($e)
439             );
440
441             return;
442         }
443
444         $this->fail();
445     }
446
447     public function testFailureIsNotIdentical()
448     {
449         $a = new stdClass;
450         $b = new stdClass;
451
452         $constraint = new PHPUnit_Framework_Constraint_Not(
453           new PHPUnit_Framework_Constraint_IsIdentical($a)
454         );
455
456         try {
457             $constraint->fail($a, '', TRUE);
458         }
459
460         catch (PHPUnit_Framework_ExpectationFailedException $e) {
461             $this->assertEquals(
462               "Failed asserting that \nstdClass Object\n(\n)\n is not identical to an object of class \"stdClass\".\n",
463               PHPUnit_Framework_TestFailure::exceptionToString($e)
464             );
465
466             return;
467         }
468
469         $this->fail();
470     }
471
472     public function testFailureIsNotIdentical2()
473     {
474         $a = new stdClass;
475
476         $constraint = new PHPUnit_Framework_Constraint_Not(
477           new PHPUnit_Framework_Constraint_IsIdentical($a)
478         );
479
480         try {
481             $constraint->fail($a, 'custom message', TRUE);
482         }
483
484         catch (PHPUnit_Framework_ExpectationFailedException $e) {
485             $this->assertEquals(
486               "custom message\nFailed asserting that \nstdClass Object\n(\n)\n is not identical to an object of class \"stdClass\".\n",
487               PHPUnit_Framework_TestFailure::exceptionToString($e)
488             );
489
490             return;
491         }
492
493         $this->fail();
494     }
495
496     public function testFailureIsInstanceOf()
497     {
498         $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf('Exception');
499
500         try {
501             $constraint->fail(new stdClass, '');
502         }
503
504         catch (PHPUnit_Framework_ExpectationFailedException $e) {
505             $this->assertEquals(
506               "Failed asserting that <stdClass> is an instance of class \"Exception\".\n",
507               PHPUnit_Framework_TestFailure::exceptionToString($e)
508             );
509
510             return;
511         }
512
513         $this->fail();
514     }
515
516     public function testFailureIsInstanceOf2()
517     {
518         $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf('Exception');
519
520         try {
521             $constraint->fail(new stdClass, 'custom message');
522         }
523
524         catch (PHPUnit_Framework_ExpectationFailedException $e) {
525             $this->assertEquals(
526               "custom message\nFailed asserting that <stdClass> is an instance of class \"Exception\".\n",
527               PHPUnit_Framework_TestFailure::exceptionToString($e)
528             );
529
530             return;
531         }
532
533         $this->fail();
534     }
535
536     public function testFailureIsNotInstanceOf()
537     {
538         $constraint = new PHPUnit_Framework_Constraint_Not(
539           new PHPUnit_Framework_Constraint_IsInstanceOf('stdClass')
540         );
541
542         try {
543             $constraint->fail(new stdClass, '', TRUE);
544         }
545
546         catch (PHPUnit_Framework_ExpectationFailedException $e) {
547             $this->assertEquals(
548               "Failed asserting that <stdClass> is not an instance of class \"stdClass\".\n",
549               PHPUnit_Framework_TestFailure::exceptionToString($e)
550             );
551
552             return;
553         }
554
555         $this->fail();
556     }
557
558     public function testFailureIsNotInstanceOf2()
559     {
560         $constraint = new PHPUnit_Framework_Constraint_Not(
561           new PHPUnit_Framework_Constraint_IsInstanceOf('stdClass')
562         );
563
564         try {
565             $constraint->fail(new stdClass, 'custom message', TRUE);
566         }
567
568         catch (PHPUnit_Framework_ExpectationFailedException $e) {
569             $this->assertEquals(
570               "custom message\nFailed asserting that <stdClass> is not an instance of class \"stdClass\".\n",
571               PHPUnit_Framework_TestFailure::exceptionToString($e)
572             );
573
574             return;
575         }
576
577         $this->fail();
578     }
579
580     public function testFailureIsType()
581     {
582         $constraint = new PHPUnit_Framework_Constraint_IsType('string');
583
584         try {
585             $constraint->fail(new stdClass, '');
586         }
587
588         catch (PHPUnit_Framework_ExpectationFailedException $e) {
589             $this->assertEquals(
590               "Failed asserting that \nstdClass Object\n(\n)\n is of type \"string\".\n",
591               PHPUnit_Framework_TestFailure::exceptionToString($e)
592             );
593
594             return;
595         }
596
597         $this->fail();
598     }
599
600     public function testFailureIsType2()
601     {
602         $constraint = new PHPUnit_Framework_Constraint_IsType('string');
603
604         try {
605             $constraint->fail(new stdClass, 'custom message');
606         }
607
608         catch (PHPUnit_Framework_ExpectationFailedException $e) {
609             $this->assertEquals(
610               "custom message\nFailed asserting that \nstdClass Object\n(\n)\n is of type \"string\".\n",
611               PHPUnit_Framework_TestFailure::exceptionToString($e)
612             );
613
614             return;
615         }
616
617         $this->fail();
618     }
619
620     public function testFailureIsNotType()
621     {
622         $constraint = new PHPUnit_Framework_Constraint_Not(
623           new PHPUnit_Framework_Constraint_IsType('string')
624         );
625
626         try {
627             $constraint->fail('', '', TRUE);
628         }
629
630         catch (PHPUnit_Framework_ExpectationFailedException $e) {
631             $this->assertEquals(
632               "Failed asserting that <string:> is not of type \"string\".\n",
633               PHPUnit_Framework_TestFailure::exceptionToString($e)
634             );
635
636             return;
637         }
638
639         $this->fail();
640     }
641
642     public function testFailureIsNotType2()
643     {
644         $constraint = new PHPUnit_Framework_Constraint_Not(
645           new PHPUnit_Framework_Constraint_IsType('string')
646         );
647
648         try {
649             $constraint->fail('', 'custom message', TRUE);
650         }
651
652         catch (PHPUnit_Framework_ExpectationFailedException $e) {
653             $this->assertEquals(
654               "custom message\nFailed asserting that <string:> is not of type \"string\".\n",
655               PHPUnit_Framework_TestFailure::exceptionToString($e)
656             );
657
658             return;
659         }
660
661         $this->fail();
662     }
663
664     public function testFailureLessThan()
665     {
666         $constraint = new PHPUnit_Framework_Constraint_LessThan(1);
667
668         try {
669             $constraint->fail(0, '');
670         }
671
672         catch (PHPUnit_Framework_ExpectationFailedException $e) {
673             $this->assertEquals(
674               "Failed asserting that <integer:0> is less than <integer:1>.\n",
675               PHPUnit_Framework_TestFailure::exceptionToString($e)
676             );
677
678             return;
679         }
680
681         $this->fail();
682     }
683
684     public function testFailureLessThan2()
685     {
686         $constraint = new PHPUnit_Framework_Constraint_LessThan(1);
687
688         try {
689             $constraint->fail(0, 'custom message');
690         }
691
692         catch (PHPUnit_Framework_ExpectationFailedException $e) {
693             $this->assertEquals(
694               "custom message\nFailed asserting that <integer:0> is less than <integer:1>.\n",
695               PHPUnit_Framework_TestFailure::exceptionToString($e)
696             );
697
698             return;
699         }
700
701         $this->fail();
702     }
703
704     public function testFailureNotLessThan()
705     {
706         $constraint = new PHPUnit_Framework_Constraint_Not(
707           new PHPUnit_Framework_Constraint_LessThan(1)
708         );
709
710         try {
711             $constraint->fail(1, '', TRUE);
712         }
713
714         catch (PHPUnit_Framework_ExpectationFailedException $e) {
715             $this->assertEquals(
716               "Failed asserting that <integer:1> is not less than <integer:1>.\n",
717               PHPUnit_Framework_TestFailure::exceptionToString($e)
718             );
719
720             return;
721         }
722
723         $this->fail();
724     }
725
726     public function testFailureNotLessThan2()
727     {
728         $constraint = new PHPUnit_Framework_Constraint_Not(
729           new PHPUnit_Framework_Constraint_LessThan(1)
730         );
731
732         try {
733             $constraint->fail(1, 'custom message', TRUE);
734         }
735
736         catch (PHPUnit_Framework_ExpectationFailedException $e) {
737             $this->assertEquals(
738               "custom message\nFailed asserting that <integer:1> is not less than <integer:1>.\n",
739               PHPUnit_Framework_TestFailure::exceptionToString($e)
740             );
741
742             return;
743         }
744
745         $this->fail();
746     }
747
748     public function testFailureObjectHasAttribute()
749     {
750         $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute('foo');
751
752         try {
753             $constraint->fail(new stdClass, '');
754         }
755
756         catch (PHPUnit_Framework_ExpectationFailedException $e) {
757             $this->assertEquals(
758               "Failed asserting that object of class \"stdClass\" has attribute \"foo\".\n",
759               PHPUnit_Framework_TestFailure::exceptionToString($e)
760             );
761
762             return;
763         }
764
765         $this->fail();
766     }
767
768     public function testFailureObjectHasAttribute2()
769     {
770         $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute('foo');
771
772         try {
773             $constraint->fail(new stdClass, 'custom message');
774         }
775
776         catch (PHPUnit_Framework_ExpectationFailedException $e) {
777             $this->assertEquals(
778               "custom message\nFailed asserting that object of class \"stdClass\" has attribute \"foo\".\n",
779               PHPUnit_Framework_TestFailure::exceptionToString($e)
780             );
781
782             return;
783         }
784
785         $this->fail();
786     }
787
788     public function testFailureObjectNotHasAttribute()
789     {
790         $constraint = new PHPUnit_Framework_Constraint_Not(
791           new PHPUnit_Framework_Constraint_ObjectHasAttribute('foo')
792         );
793
794         $o = new stdClass;
795         $o->foo = 'bar';
796
797         try {
798             $constraint->fail($o, '', TRUE);
799         }
800
801         catch (PHPUnit_Framework_ExpectationFailedException $e) {
802             $this->assertEquals(
803               "Failed asserting that object of class \"stdClass\" does not have attribute \"foo\".\n",
804               PHPUnit_Framework_TestFailure::exceptionToString($e)
805             );
806
807             return;
808         }
809
810         $this->fail();
811     }
812
813     public function testFailureObjectNotHasAttribute2()
814     {
815         $constraint = new PHPUnit_Framework_Constraint_Not(
816           new PHPUnit_Framework_Constraint_ObjectHasAttribute('foo')
817         );
818
819         $o = new stdClass;
820         $o->foo = 'bar';
821
822         try {
823             $constraint->fail($o, 'custom message', TRUE);
824         }
825
826         catch (PHPUnit_Framework_ExpectationFailedException $e) {
827             $this->assertEquals(
828               "custom message\nFailed asserting that object of class \"stdClass\" does not have attribute \"foo\".\n",
829               PHPUnit_Framework_TestFailure::exceptionToString($e)
830             );
831
832             return;
833         }
834
835         $this->fail();
836     }
837
838     public function testFailurePCREMatch()
839     {
840         $constraint = new PHPUnit_Framework_Constraint_PCREMatch('/foo/');
841
842         try {
843             $constraint->fail('barbazbar', '');
844         }
845
846         catch (PHPUnit_Framework_ExpectationFailedException $e) {
847             $this->assertEquals(
848               "Failed asserting that <string:barbazbar> matches PCRE pattern \"/foo/\".\n",
849               PHPUnit_Framework_TestFailure::exceptionToString($e)
850             );
851
852             return;
853         }
854
855         $this->fail();
856     }
857
858     public function testFailurePCREMatch2()
859     {
860         $constraint = new PHPUnit_Framework_Constraint_PCREMatch('/foo/');
861
862         try {
863             $constraint->fail('barbazbar', 'custom message');
864         }
865
866         catch (PHPUnit_Framework_ExpectationFailedException $e) {
867             $this->assertEquals(
868               "custom message\nFailed asserting that <string:barbazbar> matches PCRE pattern \"/foo/\".\n",
869               PHPUnit_Framework_TestFailure::exceptionToString($e)
870             );
871
872             return;
873         }
874
875         $this->fail();
876     }
877
878     public function testFailurePCRENotMatch()
879     {
880         $constraint = new PHPUnit_Framework_Constraint_Not(
881           new PHPUnit_Framework_Constraint_PCREMatch('/foo/')
882         );
883
884         try {
885             $constraint->fail('barfoobar', '', TRUE);
886         }
887
888         catch (PHPUnit_Framework_ExpectationFailedException $e) {
889             $this->assertEquals(
890               "Failed asserting that <string:barfoobar> does not match PCRE pattern \"/foo/\".\n",
891               PHPUnit_Framework_TestFailure::exceptionToString($e)
892             );
893
894             return;
895         }
896
897         $this->fail();
898     }
899
900     public function testFailurePCRENotMatch2()
901     {
902         $constraint = new PHPUnit_Framework_Constraint_Not(
903           new PHPUnit_Framework_Constraint_PCREMatch('/foo/')
904         );
905
906         try {
907             $constraint->fail('barfoobar', 'custom message', TRUE);
908         }
909
910         catch (PHPUnit_Framework_ExpectationFailedException $e) {
911             $this->assertEquals(
912               "custom message\nFailed asserting that <string:barfoobar> does not match PCRE pattern \"/foo/\".\n",
913               PHPUnit_Framework_TestFailure::exceptionToString($e)
914             );
915
916             return;
917         }
918
919         $this->fail();
920     }
921
922     public function testFailureStringContains()
923     {
924         $constraint = new PHPUnit_Framework_Constraint_StringContains('foo');
925
926         try {
927             $constraint->fail('barbazbar', '');
928         }
929
930         catch (PHPUnit_Framework_ExpectationFailedException $e) {
931             $this->assertEquals(
932               "Failed asserting that <string:barbazbar> contains \"foo\".\n",
933               PHPUnit_Framework_TestFailure::exceptionToString($e)
934             );
935
936             return;
937         }
938
939         $this->fail();
940     }
941
942     public function testFailureStringContains2()
943     {
944         $constraint = new PHPUnit_Framework_Constraint_StringContains('foo');
945
946         try {
947             $constraint->fail('barbazbar', 'custom message');
948         }
949
950         catch (PHPUnit_Framework_ExpectationFailedException $e) {
951             $this->assertEquals(
952               "custom message\nFailed asserting that <string:barbazbar> contains \"foo\".\n",
953               PHPUnit_Framework_TestFailure::exceptionToString($e)
954             );
955
956             return;
957         }
958
959         $this->fail();
960     }
961
962     public function testFailureStringNotContains()
963     {
964         $constraint = new PHPUnit_Framework_Constraint_Not(
965           new PHPUnit_Framework_Constraint_StringContains('foo')
966         );
967
968         try {
969             $constraint->fail('barfoobar', '', TRUE);
970         }
971
972         catch (PHPUnit_Framework_ExpectationFailedException $e) {
973             $this->assertEquals(
974               "Failed asserting that <string:barfoobar> does not contain \"foo\".\n",
975               PHPUnit_Framework_TestFailure::exceptionToString($e)
976             );
977
978             return;
979         }
980
981         $this->fail();
982     }
983
984     public function testFailureStringNotContains2()
985     {
986         $constraint = new PHPUnit_Framework_Constraint_Not(
987           new PHPUnit_Framework_Constraint_StringContains('foo')
988         );
989
990         try {
991             $constraint->fail('barfoobar', 'custom message', TRUE);
992         }
993
994         catch (PHPUnit_Framework_ExpectationFailedException $e) {
995             $this->assertEquals(
996               "custom message\nFailed asserting that <string:barfoobar> does not contain \"foo\".\n",
997               PHPUnit_Framework_TestFailure::exceptionToString($e)
998             );
999
1000             return;
1001         }
1002
1003         $this->fail();
1004     }
1005
1006     public function testFailureTraversableContains()
1007     {
1008         $constraint = new PHPUnit_Framework_Constraint_TraversableContains('foo');
1009
1010         try {
1011             $constraint->fail(array('bar'), '');
1012         }
1013
1014         catch (PHPUnit_Framework_ExpectationFailedException $e) {
1015             $this->assertEquals(
1016               "Failed asserting that an array contains <string:foo>.\n",
1017               PHPUnit_Framework_TestFailure::exceptionToString($e)
1018             );
1019
1020             return;
1021         }
1022
1023         $this->fail();
1024     }
1025
1026     public function testFailureTraversableContains2()
1027     {
1028         $constraint = new PHPUnit_Framework_Constraint_TraversableContains('foo');
1029
1030         try {
1031             $constraint->fail(array('bar'), 'custom message');
1032         }
1033
1034         catch (PHPUnit_Framework_ExpectationFailedException $e) {
1035             $this->assertEquals(
1036               "custom message\nFailed asserting that an array contains <string:foo>.\n",
1037               PHPUnit_Framework_TestFailure::exceptionToString($e)
1038             );
1039
1040             return;
1041         }
1042
1043         $this->fail();
1044     }
1045
1046     public function testFailureTraversableNotContains()
1047     {
1048         $constraint = new PHPUnit_Framework_Constraint_Not(
1049           new PHPUnit_Framework_Constraint_TraversableContains('foo')
1050         );
1051
1052         try {
1053             $constraint->fail(array('foo'), '', TRUE);
1054         }
1055
1056         catch (PHPUnit_Framework_ExpectationFailedException $e) {
1057             $this->assertEquals(
1058               "Failed asserting that an array does not contain <string:foo>.\n",
1059               PHPUnit_Framework_TestFailure::exceptionToString($e)
1060             );
1061
1062             return;
1063         }
1064
1065         $this->fail();
1066     }
1067
1068     public function testFailureTraversableNotContains2()
1069     {
1070         $constraint = new PHPUnit_Framework_Constraint_Not(
1071           new PHPUnit_Framework_Constraint_TraversableContains('foo')
1072         );
1073
1074         try {
1075             $constraint->fail(array('foo'), 'custom message', TRUE);
1076         }
1077
1078         catch (PHPUnit_Framework_ExpectationFailedException $e) {
1079             $this->assertEquals(
1080               "custom message\nFailed asserting that an array does not contain <string:foo>.\n",
1081               PHPUnit_Framework_TestFailure::exceptionToString($e)
1082             );
1083
1084             return;
1085         }
1086
1087         $this->fail();
1088     }
1089 }
1090 ?>