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