5 * Copyright (c) 2002-2009, Sebastian Bergmann <sb@sebastian-bergmann.de>.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
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
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.
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.
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
43 * @link http://www.phpunit.de/
44 * @since File available since Release 2.0.0
47 require_once 'PHPUnit/Framework/TestCase.php';
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';
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
67 class Framework_AssertTest extends PHPUnit_Framework_TestCase
69 protected $filesDirectory;
71 protected function setUp()
73 $this->filesDirectory = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR;
75 if (isset($this->html)) { return; }
76 $this->html = file_get_contents(
77 $this->filesDirectory . 'SelectorAssertionsFixture.html'
81 public function testFail()
87 catch (PHPUnit_Framework_AssertionFailedError $e) {
94 public function testAssertSplObjectStorageContainsObject()
98 $c = new SplObjectStorage;
101 $this->assertContains($a, $c);
104 $this->assertContains($b, $c);
107 catch (PHPUnit_Framework_AssertionFailedError $e) {
115 * @covers PHPUnit_Framework_Assert::assertContains
117 public function testAssertArrayContainsObject()
122 $this->assertContains($a, array($a));
125 $this->assertContains($a, array($b));
128 catch (PHPUnit_Framework_AssertionFailedError $e) {
135 public function testAssertArrayContainsString()
137 $this->assertContains('foo', array('foo'));
140 $this->assertContains('foo', array('bar'));
143 catch (PHPUnit_Framework_AssertionFailedError $e) {
150 public function testAssertArrayHasIntegerKey()
152 $this->assertArrayHasKey(0, array('foo'));
155 $this->assertArrayHasKey(1, array('foo'));
158 catch (PHPUnit_Framework_AssertionFailedError $e) {
165 public function testAssertArrayNotHasIntegerKey()
167 $this->assertArrayNotHasKey(1, array('foo'));
170 $this->assertArrayNotHasKey(0, array('foo'));
173 catch (PHPUnit_Framework_AssertionFailedError $e) {
180 public function testAssertArrayHasStringKey()
182 $this->assertArrayHasKey('foo', array('foo' => 'bar'));
185 $this->assertArrayHasKey('bar', array('foo' => 'bar'));
188 catch (PHPUnit_Framework_AssertionFailedError $e) {
195 public function testAssertArrayNotHasStringKey()
197 $this->assertArrayNotHasKey('bar', array('foo' => 'bar'));
200 $this->assertArrayNotHasKey('foo', array('foo' => 'bar'));
203 catch (PHPUnit_Framework_AssertionFailedError $e) {
210 public function testAssertIteratorContainsObject()
214 $this->assertContains($foo, new TestIterator(array($foo)));
217 $this->assertContains($foo, new TestIterator(array(new stdClass)));
220 catch (PHPUnit_Framework_AssertionFailedError $e) {
227 public function testAssertIteratorContainsString()
229 $this->assertContains('foo', new TestIterator(array('foo')));
232 $this->assertContains('foo', new TestIterator(array('bar')));
235 catch (PHPUnit_Framework_AssertionFailedError $e) {
242 public function testAssertStringContainsString()
244 $this->assertContains('foo', 'foobar');
247 $this->assertContains('foo', 'bar');
250 catch (PHPUnit_Framework_AssertionFailedError $e) {
257 public function testAssertSplObjectStorageNotContainsObject()
261 $c = new SplObjectStorage;
264 $this->assertNotContains($b, $c);
267 $this->assertNotContains($a, $c);
270 catch (PHPUnit_Framework_AssertionFailedError $e) {
278 * @covers PHPUnit_Framework_Assert::assertNotContains
280 public function testAssertArrayNotContainsObject()
285 $this->assertNotContains($a, array($b));
288 $this->assertNotContains($a, array($a));
291 catch (PHPUnit_Framework_AssertionFailedError $e) {
298 public function testAssertArrayNotContainsString()
300 $this->assertNotContains('foo', array('bar'));
303 $this->assertNotContains('foo', array('foo'));
306 catch (PHPUnit_Framework_AssertionFailedError $e) {
313 public function testAssertStringNotContainsString()
315 $this->assertNotContains('foo', 'bar');
318 $this->assertNotContains('foo', 'foo');
321 catch (PHPUnit_Framework_AssertionFailedError $e) {
328 public function testAssertArrayContainsOnlyIntegers()
330 $this->assertContainsOnly('integer', array(1, 2, 3));
333 $this->assertContainsOnly('integer', array("1", 2, 3));
336 catch (PHPUnit_Framework_AssertionFailedError $e) {
343 public function testAssertArrayNotContainsOnlyIntegers()
345 $this->assertNotContainsOnly('integer', array("1", 2, 3));
348 $this->assertNotContainsOnly('integer', array(1, 2, 3));
351 catch (PHPUnit_Framework_AssertionFailedError $e) {
358 public function testAssertArrayContainsOnlyStdClass()
360 $this->assertContainsOnly('StdClass', array(new StdClass));
363 $this->assertContainsOnly('StdClass', array('StdClass'));
366 catch (PHPUnit_Framework_AssertionFailedError $e) {
373 public function testAssertArrayNotContainsOnlyStdClass()
375 $this->assertNotContainsOnly('StdClass', array('StdClass'));
378 $this->assertNotContainsOnly('StdClass', array(new StdClass));
381 catch (PHPUnit_Framework_AssertionFailedError $e) {
388 public function testAssertEqualsArray()
390 $this->assertEquals(array('a', 'b' => array(1, 2)), array('a', 'b' => array(1, 2)));
393 $this->assertEquals(array('a', 'b' => array(1, 2)), array('a', 'b' => array(2, 1)));
396 catch (PHPUnit_Framework_AssertionFailedError $e) {
403 public function testAssertNotEqualsArray()
405 $this->assertNotEquals(array('a', 'b' => array(1, 2)), array('a', 'b' => array(2, 1)));
408 $this->assertNotEquals(array('a', 'b' => array(1, 2)), array('a', 'b' => array(1, 2)));
411 catch (PHPUnit_Framework_AssertionFailedError $e) {
418 public function testAssertEqualsFloat()
420 $this->assertEquals(2.3, 2.3);
423 $this->assertEquals(2.3, 4.2);
426 catch (PHPUnit_Framework_AssertionFailedError $e) {
433 public function testAssertNotEqualsFloat()
435 $this->assertNotEquals(2.3, 4.2);
438 $this->assertNotEquals(2.3, 2.3);
441 catch (PHPUnit_Framework_AssertionFailedError $e) {
448 public function testAssertEqualsFloatDelta()
450 $this->assertEquals(2.3, 2.5, '', 0.5);
453 $this->assertEquals(2.3, 4.2, '', 0.5);
456 catch (PHPUnit_Framework_AssertionFailedError $e) {
463 public function testAssertNotEqualsFloatDelta()
465 $this->assertNotEquals(2.3, 4.2, '', 0.5);
468 $this->assertNotEquals(2.3, 2.5, '', 0.5);
471 catch (PHPUnit_Framework_AssertionFailedError $e) {
478 public function testAssertEqualsArrayFloatDelta()
480 $this->assertEquals(array(2.3), array(2.5), '', 0.5);
483 $this->assertEquals(array(2.3), array(4.2), '', 0.5);
486 catch (PHPUnit_Framework_AssertionFailedError $e) {
493 public function testAssertNotEqualsArrayFloatDelta()
495 $this->assertNotEquals(array(2.3), array(4.2), '', 0.5);
498 $this->assertNotEquals(array(2.3), array(2.5), '', 0.5);
501 catch (PHPUnit_Framework_AssertionFailedError $e) {
508 public function testAssertEqualsStructFloatDelta()
510 $this->assertEquals(new Struct(2.3), new Struct(2.5), '', 0.5);
513 $this->assertEquals(new Struct(2.3), new Struct(4.2), '', 0.5);
516 catch (PHPUnit_Framework_AssertionFailedError $e) {
523 public function testAssertNotEqualsStructFloatDelta()
525 $this->assertNotEquals(new Struct(2.3), new Struct(4.2), '', 0.5);
528 $this->assertNotEquals(new Struct(2.3), new Struct(2.5), '', 0.5);
531 catch (PHPUnit_Framework_AssertionFailedError $e) {
538 public function testAssertEqualsArrayStructFloatDelta()
540 $this->assertEquals(array(new Struct(2.3)), array(new Struct(2.5)), '', 0.5);
543 $this->assertEquals(array(new Struct(2.3)), array(new Struct(4.2)), '', 0.5);
546 catch (PHPUnit_Framework_AssertionFailedError $e) {
553 public function testAssertNotEqualsArrayStructFloatDelta()
555 $this->assertNotEquals(array(new Struct(2.3)), array(new Struct(4.2)), '', 0.5);
558 $this->assertNotEquals(array(new Struct(2.3)), array(new Struct(2.5)), '', 0.5);
561 catch (PHPUnit_Framework_AssertionFailedError $e) {
568 public function testAssertEqualsArrayOfArrayFloatDelta()
570 $this->assertEquals(array(array(2.3)), array(array(2.5)), '', 0.5);
573 $this->assertEquals(array(array(2.3)), array(array(4.2)), '', 0.5);
576 catch (PHPUnit_Framework_AssertionFailedError $e) {
583 public function testAssertNotEqualsArrayOfArrayFloatDelta()
585 $this->assertNotEquals(array(array(2.3)), array(array(4.2)), '', 0.5);
588 $this->assertNotEquals(array(array(2.3)), array(array(2.5)), '', 0.5);
591 catch (PHPUnit_Framework_AssertionFailedError $e) {
598 public function testAssertEqualsInteger()
600 $this->assertEquals(23, 23);
603 $this->assertEquals(23, 42);
606 catch (PHPUnit_Framework_AssertionFailedError $e) {
613 public function testAssertNotEqualsInteger()
615 $this->assertNotEquals(23, 42);
618 $this->assertNotEquals(23, 23);
621 catch (PHPUnit_Framework_AssertionFailedError $e) {
628 public function testAssertEqualsObject()
630 $a = new SampleClass( 4, 8, 15);
631 $b = new SampleClass(16, 23, 42);
633 $this->assertEquals($a, $a);
636 $this->assertEquals($a, $b);
639 catch (PHPUnit_Framework_AssertionFailedError $e) {
646 public function testAssertNotEqualsObject()
648 $a = new SampleClass( 4, 8, 15);
649 $b = new SampleClass(16, 23, 42);
651 $this->assertNotEquals($a, $b);
654 $this->assertNotEquals($a, $a);
657 catch (PHPUnit_Framework_AssertionFailedError $e) {
664 public function testAssertEqualsSplObjectStorage()
666 $a = new SampleClass( 4, 8, 15);
667 $b = new SampleClass(16, 23, 42);
669 $c = new SplObjectStorage;
672 $d = new SplObjectStorage;
675 $this->assertEquals($c, $c);
678 $this->assertEquals($c, $d);
681 catch (PHPUnit_Framework_AssertionFailedError $e) {
689 * @covers PHPUnit_Framework_Assert::assertNotEquals
691 public function testAssertNotEqualsSplObjectStorage()
693 $a = new SampleClass( 4, 8, 15);
694 $b = new SampleClass(16, 23, 42);
696 $c = new SplObjectStorage;
699 $d = new SplObjectStorage;
702 $this->assertNotEquals($c, $d);
705 $this->assertNotEquals($c, $c);
708 catch (PHPUnit_Framework_AssertionFailedError $e) {
716 * @covers PHPUnit_Framework_Assert::assertEquals
718 public function testAssertEqualsString()
720 $this->assertEquals('ab', 'ab');
723 $this->assertEquals('ab', 'ba');
726 catch (PHPUnit_Framework_AssertionFailedError $e) {
733 public function testAssertNotEqualsString()
735 $this->assertNotEquals('ab', 'ba');
738 $this->assertNotEquals('ab', 'ab');
741 catch (PHPUnit_Framework_AssertionFailedError $e) {
748 public function testAssertXmlFileEqualsXmlFile()
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'
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'
762 catch (PHPUnit_Framework_AssertionFailedError $e) {
769 public function testAssertXmlFileNotEqualsXmlFile()
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'
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'
783 catch (PHPUnit_Framework_AssertionFailedError $e) {
790 public function testAssertXmlStringEqualsXmlString()
792 $this->assertXmlStringEqualsXmlString('<root/>', '<root/>');
795 $this->assertXmlStringEqualsXmlString('<foo/>', '<bar/>');
798 catch (PHPUnit_Framework_AssertionFailedError $e) {
805 public function testAssertXmlStringNotEqualsXmlString()
807 $this->assertXmlStringNotEqualsXmlString('<foo/>', '<bar/>');
810 $this->assertXmlStringNotEqualsXmlString('<root/>', '<root/>');
813 catch (PHPUnit_Framework_AssertionFailedError $e) {
820 public function testAssertEqualsDOMDocument()
822 $expected = new DOMDocument;
823 $expected->preserveWhiteSpace = FALSE;
824 $expected->loadXML('<root></root>');
826 $actual = new DOMDocument;
827 $actual->preserveWhiteSpace = FALSE;
828 $actual->loadXML('<root/>');
830 $this->assertEquals($expected, $actual);
833 $this->assertNotEquals($expected, $actual);
836 catch (PHPUnit_Framework_AssertionFailedError $e) {
843 public function testAssertEqualsDOMDocument2()
845 $expected = new DOMDocument;
846 $expected->preserveWhiteSpace = FALSE;
847 $expected->loadXML('<foo></foo>');
849 $actual = new DOMDocument;
850 $actual->preserveWhiteSpace = FALSE;
851 $actual->loadXML('<bar/>');
853 $this->assertNotEquals($expected, $actual);
856 $this->assertEquals($expected, $actual);
859 catch (PHPUnit_Framework_AssertionFailedError $e) {
866 public function testAssertEqualsDOMDocument3()
868 $expected = new DOMDocument;
869 $expected->preserveWhiteSpace = FALSE;
870 $expected->loadXML('<foo attr="bar"></foo>');
872 $actual = new DOMDocument;
873 $actual->preserveWhiteSpace = FALSE;
874 $actual->loadXML('<foo attr="bar"/>');
876 $this->assertEquals($expected, $actual);
879 $this->assertNotEquals($expected, $actual);
882 catch (PHPUnit_Framework_AssertionFailedError $e) {
889 public function testAssertEqualsDOMDocument4()
891 $expected = new DOMDocument;
892 $expected->preserveWhiteSpace = FALSE;
893 $expected->loadXML('<root><foo attr="bar"></foo></root>');
895 $actual = new DOMDocument;
896 $actual->preserveWhiteSpace = FALSE;
897 $actual->loadXML('<root><foo attr="bar"/></root>');
899 $this->assertEquals($expected, $actual);
902 $this->assertNotEquals($expected, $actual);
905 catch (PHPUnit_Framework_AssertionFailedError $e) {
912 public function testAssertEqualsDOMDocument5()
914 $expected = new DOMDocument;
915 $expected->preserveWhiteSpace = FALSE;
916 $expected->loadXML('<foo attr1="bar"/>');
918 $actual = new DOMDocument;
919 $actual->preserveWhiteSpace = FALSE;
920 $actual->loadXML('<foo attr1="foobar"/>');
922 $this->assertNotEquals($expected, $actual);
925 $this->assertEquals($expected, $actual);
928 catch (PHPUnit_Framework_AssertionFailedError $e) {
935 public function testAssertEqualsDOMDocument6()
937 $expected = new DOMDocument;
938 $expected->preserveWhiteSpace = FALSE;
939 $expected->loadXML('<foo> bar </foo>');
941 $actual = new DOMDocument;
942 $actual->preserveWhiteSpace = FALSE;
943 $actual->loadXML('<foo />');
945 $this->assertNotEquals($expected, $actual);
948 $this->assertEquals($expected, $actual);
951 catch (PHPUnit_Framework_AssertionFailedError $e) {
958 public function testAssertEqualsDOMDocument7()
960 $expected = new DOMDocument;
961 $expected->preserveWhiteSpace = FALSE;
962 $expected->loadXML('<foo xmlns="urn:myns:bar"/>');
964 $actual = new DOMDocument;
965 $actual->preserveWhiteSpace = FALSE;
966 $actual->loadXML('<foo xmlns="urn:notmyns:bar"/>');
968 $this->assertNotEquals($expected, $actual);
971 $this->assertEquals($expected, $actual);
974 catch (PHPUnit_Framework_AssertionFailedError $e) {
981 public function testAssertEqualsDOMDocument8()
983 $expected = new DOMDocument;
984 $expected->preserveWhiteSpace = FALSE;
985 $expected->loadXML("<root>\n <child/>\n</root>");
987 $actual = new DOMDocument;
988 $actual->preserveWhiteSpace = FALSE;
989 $actual->loadXML('<root><child/></root>');
991 $this->assertEquals($expected, $actual);
994 $this->assertNotEquals($expected, $actual);
997 catch (PHPUnit_Framework_AssertionFailedError $e) {
1004 public function testAssertEqualsDOMDocument9()
1006 $expected = new DOMDocument;
1007 $expected->preserveWhiteSpace = FALSE;
1008 $expected->loadXML('<foo> bar </foo>');
1010 $actual = new DOMDocument;
1011 $actual->preserveWhiteSpace = FALSE;
1012 $actual->loadXML('<foo> bir </foo>');
1014 $this->assertNotEquals($expected, $actual);
1017 $this->assertEquals($expected, $actual);
1020 catch (PHPUnit_Framework_AssertionFailedError $e) {
1027 public function testXMLStructureIsSame()
1029 $expected = new DOMDocument;
1030 $expected->load($this->filesDirectory . 'structureExpected.xml');
1032 $actual = new DOMDocument;
1033 $actual->load($this->filesDirectory . 'structureExpected.xml');
1035 $this->assertEqualXMLStructure(
1036 $expected->firstChild, $actual->firstChild, TRUE
1041 * @expectedException PHPUnit_Framework_ExpectationFailedException
1043 public function testXMLStructureWrongNumberOfAttributes()
1045 $expected = new DOMDocument;
1046 $expected->load($this->filesDirectory . 'structureExpected.xml');
1048 $actual = new DOMDocument;
1049 $actual->load($this->filesDirectory . 'structureWrongNumberOfAttributes.xml');
1051 $this->assertEqualXMLStructure(
1052 $expected->firstChild, $actual->firstChild, TRUE
1057 * @expectedException PHPUnit_Framework_ExpectationFailedException
1059 public function testXMLStructureWrongNumberOfNodes()
1061 $expected = new DOMDocument;
1062 $expected->load($this->filesDirectory . 'structureExpected.xml');
1064 $actual = new DOMDocument;
1065 $actual->load($this->filesDirectory . 'structureWrongNumberOfNodes.xml');
1067 $this->assertEqualXMLStructure(
1068 $expected->firstChild, $actual->firstChild, TRUE
1072 public function testXMLStructureIsSameButDataIsNot()
1074 $expected = new DOMDocument;
1075 $expected->load($this->filesDirectory . 'structureExpected.xml');
1077 $actual = new DOMDocument;
1078 $actual->load($this->filesDirectory . 'structureIsSameButDataIsNot.xml');
1080 $this->assertEqualXMLStructure(
1081 $expected->firstChild, $actual->firstChild, TRUE
1085 public function testXMLStructureAttributesAreSameButValuesAreNot()
1087 $expected = new DOMDocument;
1088 $expected->load($this->filesDirectory . 'structureExpected.xml');
1090 $actual = new DOMDocument;
1091 $actual->load($this->filesDirectory . 'structureAttributesAreSameButValuesAreNot.xml');
1093 $this->assertEqualXMLStructure(
1094 $expected->firstChild, $actual->firstChild, TRUE
1098 public function testXMLStructureIgnoreTextNodes()
1100 $expected = new DOMDocument;
1101 $expected->load($this->filesDirectory . 'structureExpected.xml');
1103 $actual = new DOMDocument;
1104 $actual->load($this->filesDirectory . 'structureIgnoreTextNodes.xml');
1106 $this->assertEqualXMLStructure(
1107 $expected->firstChild, $actual->firstChild, TRUE
1111 public function testAssertStringEqualsNumeric()
1113 $this->assertEquals('0', 0);
1116 $this->assertEquals('0', 1);
1119 catch (PHPUnit_Framework_AssertionFailedError $e) {
1126 public function testAssertStringEqualsNumeric2()
1128 $this->assertNotEquals('A', 0);
1131 public function testAssertFileExists()
1133 $this->assertFileExists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'AllTests.php');
1136 $this->assertFileExists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'NotExisting');
1139 catch (PHPUnit_Framework_AssertionFailedError $e) {
1146 public function testAssertFileNotExists()
1148 $this->assertFileNotExists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'NotExisting');
1151 $this->assertFileNotExists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'AllTests.php');
1154 catch (PHPUnit_Framework_AssertionFailedError $e) {
1161 public function testAssertObjectHasAttribute()
1163 $o = new WasRun('runTest');
1165 $this->assertObjectHasAttribute('wasRun', $o);
1168 $this->assertObjectHasAttribute('foo', $o);
1171 catch (PHPUnit_Framework_AssertionFailedError $e) {
1178 public function testAssertObjectNotHasAttribute()
1180 $o = new WasRun('runTest');
1182 $this->assertObjectNotHasAttribute('foo', $o);
1185 $this->assertObjectNotHasAttribute('wasRun', $o);
1188 catch (PHPUnit_Framework_AssertionFailedError $e) {
1195 public function testAssertNull()
1197 $this->assertNull(NULL);
1200 $this->assertNull(new stdClass);
1203 catch (PHPUnit_Framework_AssertionFailedError $e) {
1210 public function testAssertNotNull()
1212 $this->assertNotNull(new stdClass);
1215 $this->assertNotNull(NULL);
1218 catch (PHPUnit_Framework_AssertionFailedError $e) {
1225 public function testAssertTrue()
1227 $this->assertTrue(TRUE);
1230 $this->assertTrue(FALSE);
1233 catch (PHPUnit_Framework_AssertionFailedError $e) {
1240 public function testAssertFalse()
1242 $this->assertFalse(FALSE);
1245 $this->assertFalse(TRUE);
1248 catch (PHPUnit_Framework_AssertionFailedError $e) {
1255 public function testAssertRegExp()
1257 $this->assertRegExp('/foo/', 'foobar');
1260 $this->assertRegExp('/foo/', 'bar');
1263 catch (PHPUnit_Framework_AssertionFailedError $e) {
1270 public function testAssertNotRegExp()
1272 $this->assertNotRegExp('/foo/', 'bar');
1275 $this->assertNotRegExp('/foo/', 'foobar');
1278 catch (PHPUnit_Framework_AssertionFailedError $e) {
1285 public function testAssertSame()
1289 $this->assertSame($o, $o);
1298 catch (PHPUnit_Framework_AssertionFailedError $e) {
1305 public function testAssertSame2()
1307 $this->assertSame(TRUE, TRUE);
1308 $this->assertSame(FALSE, FALSE);
1311 $this->assertSame(TRUE, FALSE);
1314 catch (PHPUnit_Framework_AssertionFailedError $e) {
1321 public function testAssertNotSame()
1323 $this->assertNotSame(
1328 $this->assertNotSame(
1333 $this->assertNotSame(
1341 $this->assertNotSame($o, $o);
1344 catch (PHPUnit_Framework_AssertionFailedError $e) {
1351 public function testAssertNotSame2()
1353 $this->assertNotSame(TRUE, FALSE);
1354 $this->assertNotSame(FALSE, TRUE);
1357 $this->assertNotSame(TRUE, TRUE);
1360 catch (PHPUnit_Framework_AssertionFailedError $e) {
1367 public function testAssertNotSameFailsNull()
1370 $this->assertNotSame(NULL, NULL);
1373 catch (PHPUnit_Framework_AssertionFailedError $e) {
1380 public function testAssertTypeArray()
1382 $this->assertType('array', array());
1385 $this->assertType('array', 'string');
1388 catch (PHPUnit_Framework_AssertionFailedError $e) {
1395 public function testAssertNotTypeArray()
1397 $this->assertNotType('array', 'string');
1400 $this->assertNotType('array', array());
1403 catch (PHPUnit_Framework_AssertionFailedError $e) {
1410 public function testAssertTypeBool()
1412 $this->assertType('bool', TRUE);
1415 $this->assertType('bool', 'string');
1418 catch (PHPUnit_Framework_AssertionFailedError $e) {
1425 public function testAssertNotTypeBool()
1427 $this->assertNotType('bool', 'string');
1430 $this->assertNotType('bool', TRUE);
1433 catch (PHPUnit_Framework_AssertionFailedError $e) {
1440 public function testAssertTypeClass()
1442 $this->assertType('stdClass', new stdClass);
1445 $this->assertType('stdClass', new Exception);
1448 catch (PHPUnit_Framework_AssertionFailedError $e) {
1455 public function testAssertNotTypeClass()
1457 $this->assertNotType('stdClass', new Exception);
1460 $this->assertNotType('stdClass', new stdClass);
1463 catch (PHPUnit_Framework_AssertionFailedError $e) {
1470 public function testAssertTypeFloat()
1472 $this->assertType('float', 22.04);
1475 $this->assertType('integer', 'string');
1478 catch (PHPUnit_Framework_AssertionFailedError $e) {
1485 public function testAssertNotTypeFloat()
1487 $this->assertNotType('float', 'string');
1490 $this->assertNotType('float', 22.04);
1493 catch (PHPUnit_Framework_AssertionFailedError $e) {
1500 public function testAssertTypeInteger()
1502 $this->assertType('integer', 2204);
1505 $this->assertType('integer', 'string');
1508 catch (PHPUnit_Framework_AssertionFailedError $e) {
1515 public function testAssertNotTypeInteger()
1517 $this->assertNotType('integer', 'string');
1520 $this->assertNotType('integer', 2204);
1523 catch (PHPUnit_Framework_AssertionFailedError $e) {
1530 public function testAssertTypeNull()
1532 $this->assertType('null', NULL);
1535 $this->assertType('null', 'string');
1538 catch (PHPUnit_Framework_AssertionFailedError $e) {
1545 public function testAssertNotTypeNull()
1547 $this->assertNotType('null', 'string');
1550 $this->assertNotType('null', NULL);
1553 catch (PHPUnit_Framework_AssertionFailedError $e) {
1560 public function testAssertTypeObject()
1562 $this->assertType('object', new stdClass);
1565 $this->assertType('object', 'string');
1568 catch (PHPUnit_Framework_AssertionFailedError $e) {
1575 public function testAssertNotTypeObject()
1577 $this->assertNotType('object', 'string');
1580 $this->assertNotType('object', new stdClass);
1583 catch (PHPUnit_Framework_AssertionFailedError $e) {
1590 public function testAssertTypeString()
1592 $this->assertType('string', 'string');
1595 $this->assertType('string', 2204);
1598 catch (PHPUnit_Framework_AssertionFailedError $e) {
1605 public function testAssertNotTypeString()
1607 $this->assertNotType('string', 2204);
1610 $this->assertNotType('string', 'string');
1613 catch (PHPUnit_Framework_AssertionFailedError $e) {
1620 public function testGreaterThan()
1622 $this->assertGreaterThan(1, 2);
1625 $this->assertGreaterThan(2, 1);
1628 catch (PHPUnit_Framework_AssertionFailedError $e) {
1635 public function testAttributeGreaterThan()
1637 $this->assertAttributeGreaterThan(
1638 1, 'bar', new ClassWithNonPublicAttributes
1642 $this->assertAttributeGreaterThan(
1643 1, 'foo', new ClassWithNonPublicAttributes
1647 catch (PHPUnit_Framework_AssertionFailedError $e) {
1654 public function testGreaterThanOrEqual()
1656 $this->assertGreaterThanOrEqual(1, 2);
1659 $this->assertGreaterThanOrEqual(2, 1);
1662 catch (PHPUnit_Framework_AssertionFailedError $e) {
1669 public function testAttributeGreaterThanOrEqual()
1671 $this->assertAttributeGreaterThanOrEqual(
1672 1, 'bar', new ClassWithNonPublicAttributes
1676 $this->assertAttributeGreaterThanOrEqual(
1677 2, 'foo', new ClassWithNonPublicAttributes
1681 catch (PHPUnit_Framework_AssertionFailedError $e) {
1688 public function testLessThan()
1690 $this->assertLessThan(2, 1);
1693 $this->assertLessThan(1, 2);
1696 catch (PHPUnit_Framework_AssertionFailedError $e) {
1703 public function testAttributeLessThan()
1705 $this->assertAttributeLessThan(
1706 2, 'foo', new ClassWithNonPublicAttributes
1710 $this->assertAttributeLessThan(
1711 1, 'bar', new ClassWithNonPublicAttributes
1715 catch (PHPUnit_Framework_AssertionFailedError $e) {
1722 public function testLessThanOrEqual()
1724 $this->assertLessThanOrEqual(2, 1);
1727 $this->assertLessThanOrEqual(1, 2);
1730 catch (PHPUnit_Framework_AssertionFailedError $e) {
1737 public function testAttributeLessThanOrEqual()
1739 $this->assertAttributeLessThanOrEqual(
1740 2, 'foo', new ClassWithNonPublicAttributes
1744 $this->assertAttributeLessThanOrEqual(
1745 1, 'bar', new ClassWithNonPublicAttributes
1749 catch (PHPUnit_Framework_AssertionFailedError $e) {
1756 public function testGetObjectAttribute()
1758 $obj = new ClassWithNonPublicAttributes;
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'));
1767 public function testGetStaticAttribute()
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'));
1776 public function testAssertPublicAttributeContains()
1778 $obj = new ClassWithNonPublicAttributes;
1780 $this->assertAttributeContains('foo', 'publicArray', $obj);
1783 $this->assertAttributeContains('bar', 'publicArray', $obj);
1786 catch (PHPUnit_Framework_AssertionFailedError $e) {
1793 public function testAssertPublicAttributeContainsOnly()
1795 $obj = new ClassWithNonPublicAttributes;
1797 $this->assertAttributeContainsOnly('string', 'publicArray', $obj);
1800 $this->assertAttributeContainsOnly('integer', 'publicArray', $obj);
1803 catch (PHPUnit_Framework_AssertionFailedError $e) {
1810 public function testAssertPublicAttributeNotContains()
1812 $obj = new ClassWithNonPublicAttributes;
1814 $this->assertAttributeNotContains('bar', 'publicArray', $obj);
1817 $this->assertAttributeNotContains('foo', 'publicArray', $obj);
1820 catch (PHPUnit_Framework_AssertionFailedError $e) {
1827 public function testAssertPublicAttributeNotContainsOnly()
1829 $obj = new ClassWithNonPublicAttributes;
1831 $this->assertAttributeNotContainsOnly('integer', 'publicArray', $obj);
1834 $this->assertAttributeNotContainsOnly('string', 'publicArray', $obj);
1837 catch (PHPUnit_Framework_AssertionFailedError $e) {
1844 public function testAssertProtectedAttributeContains()
1846 $obj = new ClassWithNonPublicAttributes;
1848 $this->assertAttributeContains('bar', 'protectedArray', $obj);
1851 $this->assertAttributeContains('foo', 'protectedArray', $obj);
1854 catch (PHPUnit_Framework_AssertionFailedError $e) {
1861 public function testAssertProtectedAttributeNotContains()
1863 $obj = new ClassWithNonPublicAttributes;
1865 $this->assertAttributeNotContains('foo', 'protectedArray', $obj);
1868 $this->assertAttributeNotContains('bar', 'protectedArray', $obj);
1871 catch (PHPUnit_Framework_AssertionFailedError $e) {
1878 public function testAssertPrivateAttributeContains()
1880 $obj = new ClassWithNonPublicAttributes;
1882 $this->assertAttributeContains('baz', 'privateArray', $obj);
1885 $this->assertAttributeContains('foo', 'privateArray', $obj);
1888 catch (PHPUnit_Framework_AssertionFailedError $e) {
1895 public function testAssertPrivateAttributeNotContains()
1897 $obj = new ClassWithNonPublicAttributes;
1899 $this->assertAttributeNotContains('foo', 'privateArray', $obj);
1902 $this->assertAttributeNotContains('baz', 'privateArray', $obj);
1905 catch (PHPUnit_Framework_AssertionFailedError $e) {
1912 public function testAssertPublicAttributeEquals()
1914 $obj = new ClassWithNonPublicAttributes;
1916 $this->assertAttributeEquals('foo', 'publicAttribute', $obj);
1919 $this->assertAttributeEquals('bar', 'publicAttribute', $obj);
1922 catch (PHPUnit_Framework_AssertionFailedError $e) {
1929 public function testAssertPublicAttributeNotEquals()
1931 $obj = new ClassWithNonPublicAttributes;
1933 $this->assertAttributeNotEquals('bar', 'publicAttribute', $obj);
1936 $this->assertAttributeNotEquals('foo', 'publicAttribute', $obj);
1939 catch (PHPUnit_Framework_AssertionFailedError $e) {
1946 public function testAssertPublicAttributeSame()
1948 $obj = new ClassWithNonPublicAttributes;
1950 $this->assertAttributeSame('foo', 'publicAttribute', $obj);
1953 $this->assertAttributeSame('bar', 'publicAttribute', $obj);
1956 catch (PHPUnit_Framework_AssertionFailedError $e) {
1963 public function testAssertPublicAttributeNotSame()
1965 $obj = new ClassWithNonPublicAttributes;
1967 $this->assertAttributeNotSame('bar', 'publicAttribute', $obj);
1970 $this->assertAttributeNotSame('foo', 'publicAttribute', $obj);
1973 catch (PHPUnit_Framework_AssertionFailedError $e) {
1980 public function testAssertProtectedAttributeEquals()
1982 $obj = new ClassWithNonPublicAttributes;
1984 $this->assertAttributeEquals('bar', 'protectedAttribute', $obj);
1987 $this->assertAttributeEquals('foo', 'protectedAttribute', $obj);
1990 catch (PHPUnit_Framework_AssertionFailedError $e) {
1997 public function testAssertProtectedAttributeNotEquals()
1999 $obj = new ClassWithNonPublicAttributes;
2001 $this->assertAttributeNotEquals('foo', 'protectedAttribute', $obj);
2004 $this->assertAttributeNotEquals('bar', 'protectedAttribute', $obj);
2007 catch (PHPUnit_Framework_AssertionFailedError $e) {
2014 public function testAssertPrivateAttributeEquals()
2016 $obj = new ClassWithNonPublicAttributes;
2018 $this->assertAttributeEquals('baz', 'privateAttribute', $obj);
2021 $this->assertAttributeEquals('foo', 'privateAttribute', $obj);
2024 catch (PHPUnit_Framework_AssertionFailedError $e) {
2031 public function testAssertPrivateAttributeNotEquals()
2033 $obj = new ClassWithNonPublicAttributes;
2035 $this->assertAttributeNotEquals('foo', 'privateAttribute', $obj);
2038 $this->assertAttributeNotEquals('baz', 'privateAttribute', $obj);
2041 catch (PHPUnit_Framework_AssertionFailedError $e) {
2048 public function testAssertPublicStaticAttributeEquals()
2050 $this->assertAttributeEquals('foo', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2053 $this->assertAttributeEquals('bar', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2056 catch (PHPUnit_Framework_AssertionFailedError $e) {
2063 public function testAssertPublicStaticAttributeNotEquals()
2065 $this->assertAttributeNotEquals('bar', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2068 $this->assertAttributeNotEquals('foo', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2071 catch (PHPUnit_Framework_AssertionFailedError $e) {
2078 public function testAssertProtectedStaticAttributeEquals()
2080 $this->assertAttributeEquals('bar', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2083 $this->assertAttributeEquals('foo', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2086 catch (PHPUnit_Framework_AssertionFailedError $e) {
2093 public function testAssertProtectedStaticAttributeNotEquals()
2095 $this->assertAttributeNotEquals('foo', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2098 $this->assertAttributeNotEquals('bar', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2101 catch (PHPUnit_Framework_AssertionFailedError $e) {
2108 public function testAssertPrivateStaticAttributeEquals()
2110 $this->assertAttributeEquals('baz', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2113 $this->assertAttributeEquals('foo', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2116 catch (PHPUnit_Framework_AssertionFailedError $e) {
2123 public function testAssertPrivateStaticAttributeNotEquals()
2125 $this->assertAttributeNotEquals('foo', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2128 $this->assertAttributeNotEquals('baz', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2131 catch (PHPUnit_Framework_AssertionFailedError $e) {
2138 public function testClassHasPublicAttribute()
2140 $this->assertClassHasAttribute('publicAttribute', 'ClassWithNonPublicAttributes');
2143 $this->assertClassHasAttribute('attribute', 'ClassWithNonPublicAttributes');
2146 catch (PHPUnit_Framework_AssertionFailedError $e) {
2153 public function testClassNotHasPublicAttribute()
2155 $this->assertClassNotHasAttribute('attribute', 'ClassWithNonPublicAttributes');
2158 $this->assertClassNotHasAttribute('publicAttribute', 'ClassWithNonPublicAttributes');
2161 catch (PHPUnit_Framework_AssertionFailedError $e) {
2168 public function testClassHasPublicStaticAttribute()
2170 $this->assertClassHasStaticAttribute('publicStaticAttribute', 'ClassWithNonPublicAttributes');
2173 $this->assertClassHasStaticAttribute('attribute', 'ClassWithNonPublicAttributes');
2176 catch (PHPUnit_Framework_AssertionFailedError $e) {
2183 public function testClassNotHasPublicStaticAttribute()
2185 $this->assertClassNotHasStaticAttribute('attribute', 'ClassWithNonPublicAttributes');
2188 $this->assertClassNotHasStaticAttribute('publicStaticAttribute', 'ClassWithNonPublicAttributes');
2191 catch (PHPUnit_Framework_AssertionFailedError $e) {
2198 public function testObjectHasPublicAttribute()
2200 $obj = new ClassWithNonPublicAttributes;
2202 $this->assertObjectHasAttribute('publicAttribute', $obj);
2205 $this->assertObjectHasAttribute('attribute', $obj);
2208 catch (PHPUnit_Framework_AssertionFailedError $e) {
2215 public function testObjectNotHasPublicAttribute()
2217 $obj = new ClassWithNonPublicAttributes;
2219 $this->assertObjectNotHasAttribute('attribute', $obj);
2222 $this->assertObjectNotHasAttribute('publicAttribute', $obj);
2225 catch (PHPUnit_Framework_AssertionFailedError $e) {
2232 public function testObjectHasOnTheFlyAttribute()
2234 $obj = new StdClass;
2237 $this->assertObjectHasAttribute('foo', $obj);
2240 $this->assertObjectHasAttribute('bar', $obj);
2243 catch (PHPUnit_Framework_AssertionFailedError $e) {
2250 public function testObjectNotHasOnTheFlyAttribute()
2252 $obj = new StdClass;
2255 $this->assertObjectNotHasAttribute('bar', $obj);
2258 $this->assertObjectNotHasAttribute('foo', $obj);
2261 catch (PHPUnit_Framework_AssertionFailedError $e) {
2268 public function testObjectHasProtectedAttribute()
2270 $obj = new ClassWithNonPublicAttributes;
2272 $this->assertObjectHasAttribute('protectedAttribute', $obj);
2275 $this->assertObjectHasAttribute('attribute', $obj);
2278 catch (PHPUnit_Framework_AssertionFailedError $e) {
2285 public function testObjectNotHasProtectedAttribute()
2287 $obj = new ClassWithNonPublicAttributes;
2289 $this->assertObjectNotHasAttribute('attribute', $obj);
2292 $this->assertObjectNotHasAttribute('protectedAttribute', $obj);
2295 catch (PHPUnit_Framework_AssertionFailedError $e) {
2302 public function testObjectHasPrivateAttribute()
2304 $obj = new ClassWithNonPublicAttributes;
2306 $this->assertObjectHasAttribute('privateAttribute', $obj);
2309 $this->assertObjectHasAttribute('attribute', $obj);
2312 catch (PHPUnit_Framework_AssertionFailedError $e) {
2319 public function testObjectNotHasPrivateAttribute()
2321 $obj = new ClassWithNonPublicAttributes;
2323 $this->assertObjectNotHasAttribute('attribute', $obj);
2326 $this->assertObjectNotHasAttribute('privateAttribute', $obj);
2329 catch (PHPUnit_Framework_AssertionFailedError $e) {
2336 public function testAssertThatAttributeEquals()
2339 new ClassWithNonPublicAttributes,
2341 $this->equalTo('foo'),
2347 public function testAssertThatAttributeEqualTo()
2350 new ClassWithNonPublicAttributes,
2351 $this->attributeEqualTo('publicAttribute', 'foo')
2355 public function testAssertThatAnything()
2357 $this->assertThat('anything', $this->anything());
2360 public function testAssertThatAnythingAndAnything()
2365 $this->anything(), $this->anything()
2370 public function testAssertThatAnythingOrAnything()
2375 $this->anything(), $this->anything()
2380 public function testAssertThatAnythingXorNotAnything()
2386 $this->logicalNot($this->anything())
2391 public function testAssertThatContains()
2393 $this->assertThat(array('foo'), $this->contains('foo'));
2396 public function testAssertThatStringContains()
2398 $this->assertThat('barfoobar', $this->stringContains('foo'));
2401 public function testAssertThatContainsOnly()
2403 $this->assertThat(array('foo'), $this->containsOnly('string'));
2406 public function testAssertThatArrayHasKey()
2408 $this->assertThat(array('foo' => 'bar'), $this->arrayHasKey('foo'));
2411 public function testAssertThatClassHasAttribute()
2414 new ClassWithNonPublicAttributes,
2415 $this->classHasAttribute('publicAttribute')
2419 public function testAssertThatClassHasStaticAttribute()
2422 new ClassWithNonPublicAttributes,
2423 $this->classHasStaticAttribute('publicStaticAttribute')
2427 public function testAssertThatObjectHasAttribute()
2430 new ClassWithNonPublicAttributes,
2431 $this->objectHasAttribute('publicAttribute')
2435 public function testAssertThatEqualTo()
2437 $this->assertThat('foo', $this->equalTo('foo'));
2440 public function testAssertThatIdenticalTo()
2442 $value = new StdClass;
2443 $constraint = $this->identicalTo($value);
2445 $this->assertThat($value, $constraint);
2448 public function testAssertThatIsInstanceOf()
2450 $this->assertThat(new StdClass, $this->isInstanceOf('StdClass'));
2453 public function testAssertThatIsType()
2455 $this->assertThat('string', $this->isType('string'));
2458 public function testAssertThatFileExists()
2461 dirname(__FILE__) . DIRECTORY_SEPARATOR . 'AllTests.php',
2466 public function testAssertThatGreaterThan()
2468 $this->assertThat(2, $this->greaterThan(1));
2471 public function testAssertThatGreaterThanOrEqual()
2473 $this->assertThat(2, $this->greaterThanOrEqual(1));
2476 public function testAssertThatLessThan()
2478 $this->assertThat(1, $this->lessThan(2));
2481 public function testAssertThatLessThanOrEqual()
2483 $this->assertThat(1, $this->lessThanOrEqual(2));
2486 public function testAssertThatMatchesRegularExpression()
2488 $this->assertThat('foobar', $this->matchesRegularExpression('/foo/'));
2491 public function testAssertTagTypeTrue()
2493 $matcher = array('tag' => 'html');
2494 $this->assertTag($matcher, $this->html);
2498 * @expectedException PHPUnit_Framework_AssertionFailedError
2500 public function testAssertTagTypeFalse()
2502 $matcher = array('tag' => 'code');
2503 $this->assertTag($matcher, $this->html);
2506 public function testAssertTagIdTrue()
2508 $matcher = array('id' => 'test_text');
2509 $this->assertTag($matcher, $this->html);
2513 * @expectedException PHPUnit_Framework_AssertionFailedError
2515 public function testAssertTagIdFalse()
2517 $matcher = array('id' => 'test_text_doesnt_exist');
2518 $this->assertTag($matcher, $this->html);
2521 public function testAssertTagStringContentTrue()
2523 $matcher = array('id' => 'test_text',
2524 'content' => 'My test tag content');
2525 $this->assertTag($matcher, $this->html);
2529 * @expectedException PHPUnit_Framework_AssertionFailedError
2531 public function testAssertTagStringContentFalse()
2533 $matcher = array('id' => 'test_text',
2534 'content' => 'My non existent tag content');
2535 $this->assertTag($matcher, $this->html);
2538 public function testAssertTagRegexpContentTrue()
2540 $matcher = array('id' => 'test_text',
2541 'content' => 'regexp:/test tag/');
2542 $this->assertTag($matcher, $this->html);
2545 public function testAssertTagRegexpModifierContentTrue()
2547 $matcher = array('id' => 'test_text',
2548 'content' => 'regexp:/TEST TAG/i');
2549 $this->assertTag($matcher, $this->html);
2553 * @expectedException PHPUnit_Framework_AssertionFailedError
2555 public function testAssertTagRegexpContentFalse()
2557 $matcher = array('id' => 'test_text',
2558 'content' => 'regexp:/asdf/');
2559 $this->assertTag($matcher, $this->html);
2562 public function testAssertTagAttributesTrueA()
2564 $matcher = array('tag' => 'span',
2565 'attributes' => array('class' => 'test_class'));
2566 $this->assertTag($matcher, $this->html);
2569 public function testAssertTagAttributesTrueB()
2571 $matcher = array('tag' => 'div',
2572 'attributes' => array('id' => 'test_child_id'));
2573 $this->assertTag($matcher, $this->html);
2577 * @expectedException PHPUnit_Framework_AssertionFailedError
2579 public function testAssertTagAttributesFalse()
2581 $matcher = array('tag' => 'span',
2582 'attributes' => array('class' => 'test_missing_class'));
2583 $this->assertTag($matcher, $this->html);
2586 public function testAssertTagAttributesRegexpTrueA()
2588 $matcher = array('tag' => 'span',
2589 'attributes' => array('class' => 'regexp:/.+_class/'));
2590 $this->assertTag($matcher, $this->html);
2593 public function testAssertTagAttributesRegexpTrueB()
2595 $matcher = array('tag' => 'div',
2596 'attributes' => array('id' => 'regexp:/.+_child_.+/'));
2597 $this->assertTag($matcher, $this->html);
2600 public function testAssertTagAttributesRegexpModifierTrue()
2602 $matcher = array('tag' => 'div',
2603 'attributes' => array('id' => 'regexp:/.+_CHILD_.+/i'));
2604 $this->assertTag($matcher, $this->html);
2608 * @expectedException PHPUnit_Framework_AssertionFailedError
2610 public function testAssertTagAttributesRegexpModifierFalse()
2612 $matcher = array('tag' => 'div',
2613 'attributes' => array('id' => 'regexp:/.+_CHILD_.+/'));
2614 $this->assertTag($matcher, $this->html);
2618 * @expectedException PHPUnit_Framework_AssertionFailedError
2620 public function testAssertTagAttributesRegexpFalse()
2622 $matcher = array('tag' => 'span',
2623 'attributes' => array('class' => 'regexp:/.+_missing_.+/'));
2624 $this->assertTag($matcher, $this->html);
2627 public function testAssertTagAttributesMultiPartClassTrueA()
2629 $matcher = array('tag' => 'div',
2630 'id' => 'test_multi_class',
2631 'attributes' => array('class' => 'multi class'));
2632 $this->assertTag($matcher, $this->html);
2635 public function testAssertTagAttributesMultiPartClassTrueB()
2637 $matcher = array('tag' => 'div',
2638 'id' => 'test_multi_class',
2639 'attributes' => array('class' => 'multi'));
2640 $this->assertTag($matcher, $this->html);
2644 * @expectedException PHPUnit_Framework_AssertionFailedError
2646 public function testAssertTagAttributesMultiPartClassFalse()
2648 $matcher = array('tag' => 'div',
2649 'id' => 'test_multi_class',
2650 'attributes' => array('class' => 'mul'));
2651 $this->assertTag($matcher, $this->html);
2654 public function testAssertTagParentTrue()
2656 $matcher = array('tag' => 'head',
2657 'parent' => array('tag' => 'html'));
2658 $this->assertTag($matcher, $this->html);
2662 * @expectedException PHPUnit_Framework_AssertionFailedError
2664 public function testAssertTagParentFalse()
2666 $matcher = array('tag' => 'head',
2667 'parent' => array('tag' => 'div'));
2668 $this->assertTag($matcher, $this->html);
2671 public function testAssertTagChildTrue()
2673 $matcher = array('tag' => 'html',
2674 'child' => array('tag' => 'head'));
2675 $this->assertTag($matcher, $this->html);
2679 * @expectedException PHPUnit_Framework_AssertionFailedError
2681 public function testAssertTagChildFalse()
2683 $matcher = array('tag' => 'html',
2684 'child' => array('tag' => 'div'));
2685 $this->assertTag($matcher, $this->html);
2688 public function testAssertTagAncestorTrue()
2690 $matcher = array('tag' => 'div',
2691 'ancestor' => array('tag' => 'html'));
2692 $this->assertTag($matcher, $this->html);
2696 * @expectedException PHPUnit_Framework_AssertionFailedError
2698 public function testAssertTagAncestorFalse()
2700 $matcher = array('tag' => 'html',
2701 'ancestor' => array('tag' => 'div'));
2702 $this->assertTag($matcher, $this->html);
2705 public function testAssertTagDescendantTrue()
2707 $matcher = array('tag' => 'html',
2708 'descendant' => array('tag' => 'div'));
2709 $this->assertTag($matcher, $this->html);
2713 * @expectedException PHPUnit_Framework_AssertionFailedError
2715 public function testAssertTagDescendantFalse()
2717 $matcher = array('tag' => 'div',
2718 'descendant' => array('tag' => 'html'));
2719 $this->assertTag($matcher, $this->html);
2722 public function testAssertTagChildrenCountTrue()
2724 $matcher = array('tag' => 'ul',
2725 'children' => array('count' => 3));
2726 $this->assertTag($matcher, $this->html);
2730 * @expectedException PHPUnit_Framework_AssertionFailedError
2732 public function testAssertTagChildrenCountFalse()
2734 $matcher = array('tag' => 'ul',
2735 'children' => array('count' => 5));
2736 $this->assertTag($matcher, $this->html);
2739 public function testAssertTagChildrenLessThanTrue()
2741 $matcher = array('tag' => 'ul',
2742 'children' => array('less_than' => 10));
2743 $this->assertTag($matcher, $this->html);
2747 * @expectedException PHPUnit_Framework_AssertionFailedError
2749 public function testAssertTagChildrenLessThanFalse()
2751 $matcher = array('tag' => 'ul',
2752 'children' => array('less_than' => 2));
2753 $this->assertTag($matcher, $this->html);
2756 public function testAssertTagChildrenGreaterThanTrue()
2758 $matcher = array('tag' => 'ul',
2759 'children' => array('greater_than' => 2));
2760 $this->assertTag($matcher, $this->html);
2764 * @expectedException PHPUnit_Framework_AssertionFailedError
2766 public function testAssertTagChildrenGreaterThanFalse()
2768 $matcher = array('tag' => 'ul',
2769 'children' => array('greater_than' => 10));
2770 $this->assertTag($matcher, $this->html);
2773 public function testAssertTagChildrenOnlyTrue()
2775 $matcher = array('tag' => 'ul',
2776 'children' => array('only' => array('tag' =>'li')));
2777 $this->assertTag($matcher, $this->html);
2781 * @expectedException PHPUnit_Framework_AssertionFailedError
2783 public function testAssertTagChildrenOnlyFalse()
2785 $matcher = array('tag' => 'ul',
2786 'children' => array('only' => array('tag' =>'div')));
2787 $this->assertTag($matcher, $this->html);
2790 public function testAssertTagTypeIdTrueA()
2792 $matcher = array('tag' => 'ul', 'id' => 'my_ul');
2793 $this->assertTag($matcher, $this->html);
2796 public function testAssertTagTypeIdTrueB()
2798 $matcher = array('id' => 'my_ul', 'tag' => 'ul');
2799 $this->assertTag($matcher, $this->html);
2802 public function testAssertTagTypeIdTrueC()
2804 $matcher = array('tag' => 'input', 'id' => 'input_test_id');
2805 $this->assertTag($matcher, $this->html);
2809 * @expectedException PHPUnit_Framework_AssertionFailedError
2811 public function testAssertTagTypeIdFalse()
2813 $matcher = array('tag' => 'div', 'id' => 'my_ul');
2814 $this->assertTag($matcher, $this->html);
2817 public function testAssertTagContentAttributes()
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);
2826 public function testAssertParentContentAttributes()
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);
2836 public function testAssertChildContentAttributes()
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);
2847 public function testAssertChildSubChildren()
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);
2855 public function testAssertAncestorContentAttributes()
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);
2865 public function testAssertDescendantContentAttributes()
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);
2875 public function testAssertChildrenContentAttributes()
2877 $matcher = array('id' => 'test_children',
2878 'content' => 'My Children',
2879 'attributes' => array('class' => 'children'),
2881 'children' => array('less_than' => '25',
2882 'greater_than' => '2',
2883 'only' => array('tag' => 'div',
2884 'attributes' => array('class' => 'my_child'))
2886 $this->assertTag($matcher, $this->html);
2889 public function testAssertNotTagTypeIdFalse()
2891 $matcher = array('tag' => 'div', 'id' => 'my_ul');
2892 $this->assertNotTag($matcher, $this->html);
2896 * @expectedException PHPUnit_Framework_AssertionFailedError
2898 public function testAssertNotTagContentAttributes()
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);
2907 public function testAssertSelectCountPresentTrue()
2909 $selector = 'div#test_id';
2911 $this->assertSelectCount($selector, $count, $this->html);
2915 * @expectedException PHPUnit_Framework_AssertionFailedError
2917 public function testAssertSelectCountPresentFalse()
2919 $selector = 'div#non_existent';
2922 $this->assertSelectCount($selector, $count, $this->html);
2925 public function testAssertSelectCountNotPresentTrue()
2927 $selector = 'div#non_existent';
2930 $this->assertSelectCount($selector, $count, $this->html);
2934 * @expectedException PHPUnit_Framework_AssertionFailedError
2936 public function testAssertSelectNotPresentFalse()
2938 $selector = 'div#test_id';
2941 $this->assertSelectCount($selector, $count, $this->html);
2944 public function testAssertSelectCountChildTrue()
2946 $selector = '#my_ul > li';
2949 $this->assertSelectCount($selector, $count, $this->html);
2953 * @expectedException PHPUnit_Framework_AssertionFailedError
2955 public function testAssertSelectCountChildFalse()
2957 $selector = '#my_ul > li';
2960 $this->assertSelectCount($selector, $count, $this->html);
2963 public function testAssertSelectCountDescendantTrue()
2965 $selector = '#my_ul li';
2968 $this->assertSelectCount($selector, $count, $this->html);
2972 * @expectedException PHPUnit_Framework_AssertionFailedError
2974 public function testAssertSelectCountDescendantFalse()
2976 $selector = '#my_ul li';
2979 $this->assertSelectCount($selector, $count, $this->html);
2982 public function testAssertSelectCountGreaterThanTrue()
2984 $selector = '#my_ul > li';
2985 $range = array('>' => 2);
2987 $this->assertSelectCount($selector, $range, $this->html);
2991 * @expectedException PHPUnit_Framework_AssertionFailedError
2993 public function testAssertSelectCountGreaterThanFalse()
2995 $selector = '#my_ul > li';
2996 $range = array('>' => 3);
2998 $this->assertSelectCount($selector, $range, $this->html);
3001 public function testAssertSelectCountGreaterThanEqualToTrue()
3003 $selector = '#my_ul > li';
3004 $range = array('>=' => 3);
3006 $this->assertSelectCount($selector, $range, $this->html);
3010 * @expectedException PHPUnit_Framework_AssertionFailedError
3012 public function testAssertSelectCountGreaterThanEqualToFalse()
3014 $selector = '#my_ul > li';
3015 $range = array('>=' => 4);
3017 $this->assertSelectCount($selector, $range, $this->html);
3020 public function testAssertSelectCountLessThanTrue()
3022 $selector = '#my_ul > li';
3023 $range = array('<' => 4);
3025 $this->assertSelectCount($selector, $range, $this->html);
3029 * @expectedException PHPUnit_Framework_AssertionFailedError
3031 public function testAssertSelectCountLessThanFalse()
3033 $selector = '#my_ul > li';
3034 $range = array('<' => 3);
3036 $this->assertSelectCount($selector, $range, $this->html);
3039 public function testAssertSelectCountLessThanEqualToTrue()
3041 $selector = '#my_ul > li';
3042 $range = array('<=' => 3);
3044 $this->assertSelectCount($selector, $range, $this->html);
3048 * @expectedException PHPUnit_Framework_AssertionFailedError
3050 public function testAssertSelectCountLessThanEqualToFalse()
3052 $selector = '#my_ul > li';
3053 $range = array('<=' => 2);
3055 $this->assertSelectCount($selector, $range, $this->html);
3058 public function testAssertSelectCountRangeTrue()
3060 $selector = '#my_ul > li';
3061 $range = array('>' => 2, '<' => 4);
3063 $this->assertSelectCount($selector, $range, $this->html);
3067 * @expectedException PHPUnit_Framework_AssertionFailedError
3069 public function testAssertSelectCountRangeFalse()
3071 $selector = '#my_ul > li';
3072 $range = array('>' => 1, '<' => 3);
3074 $this->assertSelectCount($selector, $range, $this->html);
3077 public function testAssertSelectEqualsContentPresentTrue()
3079 $selector = 'span.test_class';
3080 $content = 'Test Class Text';
3082 $this->assertSelectEquals($selector, $content, TRUE, $this->html);
3086 * @expectedException PHPUnit_Framework_AssertionFailedError
3088 public function testAssertSelectEqualsContentPresentFalse()
3090 $selector = 'span.test_class';
3091 $content = 'Test Nonexistent';
3093 $this->assertSelectEquals($selector, $content, TRUE, $this->html);
3096 public function testAssertSelectEqualsContentNotPresentTrue()
3098 $selector = 'span.test_class';
3099 $content = 'Test Nonexistent';
3101 $this->assertSelectEquals($selector, $content, FALSE, $this->html);
3105 * @expectedException PHPUnit_Framework_AssertionFailedError
3107 public function testAssertSelectEqualsContentNotPresentFalse()
3109 $selector = 'span.test_class';
3110 $content = 'Test Class Text';
3112 $this->assertSelectEquals($selector, $content, FALSE, $this->html);
3115 public function testAssertSelectRegExpContentPresentTrue()
3117 $selector = 'span.test_class';
3118 $regexp = '/Test.*Text/';
3120 $this->assertSelectRegExp($selector, $regexp, TRUE, $this->html);
3123 public function testAssertSelectRegExpContentPresentFalse()
3125 $selector = 'span.test_class';
3126 $regexp = '/Nonexistant/';
3128 $this->assertSelectRegExp($selector, $regexp, FALSE, $this->html);
3131 public function testMarkTestIncomplete()
3134 $this->markTestIncomplete('incomplete');
3137 catch (PHPUnit_Framework_IncompleteTestError $e) {
3138 $this->assertEquals('incomplete', $e->getMessage());
3146 public function testMarkTestSkipped()
3149 $this->markTestSkipped('skipped');
3152 catch (PHPUnit_Framework_SkippedTestError $e) {
3153 $this->assertEquals('skipped', $e->getMessage());