3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * @since Class available since Release 2.0.0
14 class Framework_AssertTest extends PHPUnit_Framework_TestCase
19 private $filesDirectory;
21 protected function setUp()
23 $this->filesDirectory = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR;
27 * @covers PHPUnit_Framework_Assert::fail
29 public function testFail()
33 } catch (PHPUnit_Framework_AssertionFailedError $e) {
37 throw new PHPUnit_Framework_AssertionFailedError('Fail did not throw fail exception');
41 * @covers PHPUnit_Framework_Assert::assertContains
43 public function testAssertSplObjectStorageContainsObject()
47 $c = new SplObjectStorage;
50 $this->assertContains($a, $c);
53 $this->assertContains($b, $c);
54 } catch (PHPUnit_Framework_AssertionFailedError $e) {
62 * @covers PHPUnit_Framework_Assert::assertContains
64 public function testAssertArrayContainsObject()
69 $this->assertContains($a, array($a));
72 $this->assertContains($a, array($b));
73 } catch (PHPUnit_Framework_AssertionFailedError $e) {
81 * @covers PHPUnit_Framework_Assert::assertContains
83 public function testAssertArrayContainsString()
85 $this->assertContains('foo', array('foo'));
88 $this->assertContains('foo', array('bar'));
89 } catch (PHPUnit_Framework_AssertionFailedError $e) {
97 * @covers PHPUnit_Framework_Assert::assertContains
99 public function testAssertArrayContainsNonObject()
101 $this->assertContains('foo', array(true));
104 $this->assertContains('foo', array(true), '', false, true, true);
105 } catch (PHPUnit_Framework_AssertionFailedError $e) {
113 * @covers PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf
115 public function testAssertContainsOnlyInstancesOf()
121 $this->assertContainsOnlyInstancesOf('Book', $test);
122 $this->assertContainsOnlyInstancesOf('stdClass', array(new stdClass()));
128 $this->assertContainsOnlyInstancesOf('Book', $test2);
129 } catch (PHPUnit_Framework_AssertionFailedError $e) {
136 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
137 * @expectedException PHPUnit_Framework_Exception
139 public function testAssertArrayHasKeyThrowsExceptionForInvalidFirstArgument()
141 $this->assertArrayHasKey(null, array());
145 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
146 * @expectedException PHPUnit_Framework_Exception
148 public function testAssertArrayHasKeyThrowsExceptionForInvalidSecondArgument()
150 $this->assertArrayHasKey(0, null);
154 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
156 public function testAssertArrayHasIntegerKey()
158 $this->assertArrayHasKey(0, array('foo'));
161 $this->assertArrayHasKey(1, array('foo'));
162 } catch (PHPUnit_Framework_AssertionFailedError $e) {
170 * @covers PHPUnit_Framework_Assert::assertArraySubset
171 * @covers PHPUnit_Framework_Constraint_ArraySubset
173 public function testAssertArraySubset()
178 'c' => array('a2' => 'item a2', 'b2' => 'item b2'),
179 'd' => array('a2' => array('a3' => 'item a3', 'b3' => 'item b3'))
182 $this->assertArraySubset(array('a' => 'item a', 'c' => array('a2' => 'item a2')), $array);
183 $this->assertArraySubset(array('a' => 'item a', 'd' => array('a2' => array('b3' => 'item b3'))), $array);
185 $arrayAccessData = new ArrayObject($array);
187 $this->assertArraySubset(array('a' => 'item a', 'c' => array('a2' => 'item a2')), $arrayAccessData);
188 $this->assertArraySubset(array('a' => 'item a', 'd' => array('a2' => array('b3' => 'item b3'))), $arrayAccessData);
191 $this->assertArraySubset(array('a' => 'bad value'), $array);
192 } catch (PHPUnit_Framework_AssertionFailedError $e) {
196 $this->assertArraySubset(array('d' => array('a2' => array('bad index' => 'item b3'))), $array);
197 } catch (PHPUnit_Framework_AssertionFailedError $e) {
205 * @covers PHPUnit_Framework_Assert::assertArraySubset
206 * @covers PHPUnit_Framework_Constraint_ArraySubset
208 public function testAssertArraySubsetWithDeepNestedArrays()
220 $this->assertArraySubset(array('path' => array()), $array);
221 $this->assertArraySubset(array('path' => array('to' => array())), $array);
222 $this->assertArraySubset(array('path' => array('to' => array('the' => array()))), $array);
223 $this->assertArraySubset(array('path' => array('to' => array('the' => array('cake' => 'is a lie')))), $array);
226 $this->assertArraySubset(array('path' => array('to' => array('the' => array('cake' => 'is not a lie')))), $array);
227 } catch (PHPUnit_Framework_AssertionFailedError $e) {
235 * @covers PHPUnit_Framework_Assert::assertArraySubset
236 * @covers PHPUnit_Framework_Constraint_ArraySubset
238 public function testAssertArraySubsetWithNoStrictCheckAndObjects()
240 $obj = new \stdClass;
242 $array = array('a' => $obj);
244 $this->assertArraySubset(array('a' => $reference), $array);
245 $this->assertArraySubset(array('a' => new \stdClass), $array);
249 * @covers PHPUnit_Framework_Assert::assertArraySubset
250 * @covers PHPUnit_Framework_Constraint_ArraySubset
252 public function testAssertArraySubsetWithStrictCheckAndObjects()
254 $obj = new \stdClass;
256 $array = array('a' => $obj);
258 $this->assertArraySubset(array('a' => $reference), $array, true);
261 $this->assertArraySubset(array('a' => new \stdClass), $array, true);
262 } catch (PHPUnit_Framework_AssertionFailedError $e) {
266 $this->fail('Strict recursive array check fail.');
270 * @covers PHPUnit_Framework_Assert::assertArraySubset
271 * @covers PHPUnit_Framework_Constraint_ArraySubset
272 * @expectedException PHPUnit_Framework_Exception
273 * @expectedExceptionMessage array or ArrayAccess
274 * @dataProvider assertArraySubsetInvalidArgumentProvider
276 public function testAssertArraySubsetRaisesExceptionForInvalidArguments($partial, $subject)
278 $this->assertArraySubset($partial, $subject);
284 public function assertArraySubsetInvalidArgumentProvider()
287 array(false, array()),
288 array(array(), false),
293 * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey
294 * @expectedException PHPUnit_Framework_Exception
296 public function testAssertArrayNotHasKeyThrowsExceptionForInvalidFirstArgument()
298 $this->assertArrayNotHasKey(null, array());
302 * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey
303 * @expectedException PHPUnit_Framework_Exception
305 public function testAssertArrayNotHasKeyThrowsExceptionForInvalidSecondArgument()
307 $this->assertArrayNotHasKey(0, null);
311 * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey
313 public function testAssertArrayNotHasIntegerKey()
315 $this->assertArrayNotHasKey(1, array('foo'));
318 $this->assertArrayNotHasKey(0, array('foo'));
319 } catch (PHPUnit_Framework_AssertionFailedError $e) {
327 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
329 public function testAssertArrayHasStringKey()
331 $this->assertArrayHasKey('foo', array('foo' => 'bar'));
334 $this->assertArrayHasKey('bar', array('foo' => 'bar'));
335 } catch (PHPUnit_Framework_AssertionFailedError $e) {
343 * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey
345 public function testAssertArrayNotHasStringKey()
347 $this->assertArrayNotHasKey('bar', array('foo' => 'bar'));
350 $this->assertArrayNotHasKey('foo', array('foo' => 'bar'));
351 } catch (PHPUnit_Framework_AssertionFailedError $e) {
359 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
361 public function testAssertArrayHasKeyAcceptsArrayObjectValue()
363 $array = new ArrayObject();
364 $array['foo'] = 'bar';
365 $this->assertArrayHasKey('foo', $array);
369 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
370 * @expectedException PHPUnit_Framework_AssertionFailedError
372 public function testAssertArrayHasKeyProperlyFailsWithArrayObjectValue()
374 $array = new ArrayObject();
375 $array['bar'] = 'bar';
376 $this->assertArrayHasKey('foo', $array);
380 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
382 public function testAssertArrayHasKeyAcceptsArrayAccessValue()
384 $array = new SampleArrayAccess();
385 $array['foo'] = 'bar';
386 $this->assertArrayHasKey('foo', $array);
390 * @covers PHPUnit_Framework_Assert::assertArrayHasKey
391 * @expectedException PHPUnit_Framework_AssertionFailedError
393 public function testAssertArrayHasKeyProperlyFailsWithArrayAccessValue()
395 $array = new SampleArrayAccess();
396 $array['bar'] = 'bar';
397 $this->assertArrayHasKey('foo', $array);
401 * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey
403 public function testAssertArrayNotHasKeyAcceptsArrayAccessValue()
405 $array = new ArrayObject();
406 $array['foo'] = 'bar';
407 $this->assertArrayNotHasKey('bar', $array);
411 * @covers PHPUnit_Framework_Assert::assertArrayNotHasKey
412 * @expectedException PHPUnit_Framework_AssertionFailedError
414 public function testAssertArrayNotHasKeyPropertlyFailsWithArrayAccessValue()
416 $array = new ArrayObject();
417 $array['bar'] = 'bar';
418 $this->assertArrayNotHasKey('bar', $array);
422 * @covers PHPUnit_Framework_Assert::assertContains
423 * @expectedException PHPUnit_Framework_Exception
425 public function testAssertContainsThrowsException()
427 $this->assertContains(null, null);
431 * @covers PHPUnit_Framework_Assert::assertContains
433 public function testAssertIteratorContainsObject()
437 $this->assertContains($foo, new TestIterator(array($foo)));
440 $this->assertContains($foo, new TestIterator(array(new stdClass)));
441 } catch (PHPUnit_Framework_AssertionFailedError $e) {
449 * @covers PHPUnit_Framework_Assert::assertContains
451 public function testAssertIteratorContainsString()
453 $this->assertContains('foo', new TestIterator(array('foo')));
456 $this->assertContains('foo', new TestIterator(array('bar')));
457 } catch (PHPUnit_Framework_AssertionFailedError $e) {
465 * @covers PHPUnit_Framework_Assert::assertContains
467 public function testAssertStringContainsString()
469 $this->assertContains('foo', 'foobar');
472 $this->assertContains('foo', 'bar');
473 } catch (PHPUnit_Framework_AssertionFailedError $e) {
481 * @covers PHPUnit_Framework_Assert::assertNotContains
482 * @expectedException PHPUnit_Framework_Exception
484 public function testAssertNotContainsThrowsException()
486 $this->assertNotContains(null, null);
490 * @covers PHPUnit_Framework_Assert::assertNotContains
492 public function testAssertSplObjectStorageNotContainsObject()
496 $c = new SplObjectStorage;
499 $this->assertNotContains($b, $c);
502 $this->assertNotContains($a, $c);
503 } catch (PHPUnit_Framework_AssertionFailedError $e) {
511 * @covers PHPUnit_Framework_Assert::assertNotContains
513 public function testAssertArrayNotContainsObject()
518 $this->assertNotContains($a, array($b));
521 $this->assertNotContains($a, array($a));
522 } catch (PHPUnit_Framework_AssertionFailedError $e) {
530 * @covers PHPUnit_Framework_Assert::assertNotContains
532 public function testAssertArrayNotContainsString()
534 $this->assertNotContains('foo', array('bar'));
537 $this->assertNotContains('foo', array('foo'));
538 } catch (PHPUnit_Framework_AssertionFailedError $e) {
546 * @covers PHPUnit_Framework_Assert::assertNotContains
548 public function testAssertArrayNotContainsNonObject()
550 $this->assertNotContains('foo', array(true), '', false, true, true);
553 $this->assertNotContains('foo', array(true));
554 } catch (PHPUnit_Framework_AssertionFailedError $e) {
562 * @covers PHPUnit_Framework_Assert::assertNotContains
564 public function testAssertStringNotContainsString()
566 $this->assertNotContains('foo', 'bar');
569 $this->assertNotContains('foo', 'foo');
570 } catch (PHPUnit_Framework_AssertionFailedError $e) {
578 * @covers PHPUnit_Framework_Assert::assertContainsOnly
579 * @expectedException PHPUnit_Framework_Exception
581 public function testAssertContainsOnlyThrowsException()
583 $this->assertContainsOnly(null, null);
587 * @covers PHPUnit_Framework_Assert::assertNotContainsOnly
588 * @expectedException PHPUnit_Framework_Exception
590 public function testAssertNotContainsOnlyThrowsException()
592 $this->assertNotContainsOnly(null, null);
596 * @covers PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf
597 * @expectedException PHPUnit_Framework_Exception
599 public function testAssertContainsOnlyInstancesOfThrowsException()
601 $this->assertContainsOnlyInstancesOf(null, null);
605 * @covers PHPUnit_Framework_Assert::assertContainsOnly
607 public function testAssertArrayContainsOnlyIntegers()
609 $this->assertContainsOnly('integer', array(1, 2, 3));
612 $this->assertContainsOnly('integer', array('1', 2, 3));
613 } catch (PHPUnit_Framework_AssertionFailedError $e) {
621 * @covers PHPUnit_Framework_Assert::assertNotContainsOnly
623 public function testAssertArrayNotContainsOnlyIntegers()
625 $this->assertNotContainsOnly('integer', array('1', 2, 3));
628 $this->assertNotContainsOnly('integer', array(1, 2, 3));
629 } catch (PHPUnit_Framework_AssertionFailedError $e) {
637 * @covers PHPUnit_Framework_Assert::assertContainsOnly
639 public function testAssertArrayContainsOnlyStdClass()
641 $this->assertContainsOnly('StdClass', array(new stdClass));
644 $this->assertContainsOnly('StdClass', array('StdClass'));
645 } catch (PHPUnit_Framework_AssertionFailedError $e) {
653 * @covers PHPUnit_Framework_Assert::assertNotContainsOnly
655 public function testAssertArrayNotContainsOnlyStdClass()
657 $this->assertNotContainsOnly('StdClass', array('StdClass'));
660 $this->assertNotContainsOnly('StdClass', array(new stdClass));
661 } catch (PHPUnit_Framework_AssertionFailedError $e) {
668 protected function sameValues()
670 $object = new SampleClass(4, 8, 15);
671 // cannot use $filesDirectory, because neither setUp() nor
672 // setUpBeforeClass() are executed before the data providers
673 $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'foo.xml';
674 $resource = fopen($file, 'r');
686 array(log(0), log(0)),
688 array(array(), array()),
689 array(array(0 => 1), array(0 => 1)),
690 array(array(0 => null), array(0 => null)),
691 array(array('a', 'b' => array(1, 2)), array('a', 'b' => array(1, 2))),
693 array($object, $object),
695 array($resource, $resource),
699 protected function notEqualValues()
701 // cyclic dependencies
703 $book1->author = new Author('Terry Pratchett');
704 $book1->author->books[] = $book1;
706 $book2->author = new Author('Terry Pratch');
707 $book2->author->books[] = $book2;
710 $book3->author = 'Terry Pratchett';
711 $book4 = new stdClass;
712 $book4->author = 'Terry Pratchett';
714 $object1 = new SampleClass(4, 8, 15);
715 $object2 = new SampleClass(16, 23, 42);
716 $object3 = new SampleClass(4, 8, 15);
717 $storage1 = new SplObjectStorage;
718 $storage1->attach($object1);
719 $storage2 = new SplObjectStorage;
720 $storage2->attach($object3); // same content, different object
722 // cannot use $filesDirectory, because neither setUp() nor
723 // setUpBeforeClass() are executed before the data providers
724 $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'foo.xml';
730 // https://github.com/sebastianbergmann/phpunit/issues/1023
731 array('9E6666666','9E7777777'),
737 array(2.3, 4.2, 0.5),
738 array(array(2.3), array(4.2), 0.5),
739 array(array(array(2.3)), array(array(4.2)), 0.5),
740 array(new Struct(2.3), new Struct(4.2), 0.5),
741 array(array(new Struct(2.3)), array(new Struct(4.2)), 0.5),
745 array(array(), array(0 => 1)),
746 array(array(0 => 1), array()),
747 array(array(0 => null), array()),
748 array(array(0 => 1, 1 => 2), array(0 => 1, 1 => 3)),
749 array(array('a', 'b' => array(1, 2)), array('a', 'b' => array(2, 1))),
751 array(new SampleClass(4, 8, 15), new SampleClass(16, 23, 42)),
752 array($object1, $object2),
753 array($book1, $book2),
754 array($book3, $book4), // same content, different class
756 array(fopen($file, 'r'), fopen($file, 'r')),
758 array($storage1, $storage2),
761 PHPUnit_Util_XML::load('<root></root>'),
762 PHPUnit_Util_XML::load('<bar/>'),
765 PHPUnit_Util_XML::load('<foo attr1="bar"/>'),
766 PHPUnit_Util_XML::load('<foo attr1="foobar"/>'),
769 PHPUnit_Util_XML::load('<foo> bar </foo>'),
770 PHPUnit_Util_XML::load('<foo />'),
773 PHPUnit_Util_XML::load('<foo xmlns="urn:myns:bar"/>'),
774 PHPUnit_Util_XML::load('<foo xmlns="urn:notmyns:bar"/>'),
777 PHPUnit_Util_XML::load('<foo> bar </foo>'),
778 PHPUnit_Util_XML::load('<foo> bir </foo>'),
781 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
782 new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/New_York')),
785 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
786 new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/New_York')),
790 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
791 new DateTime('2013-03-29 05:13:35', new DateTimeZone('America/New_York')),
795 new DateTime('2013-03-29', new DateTimeZone('America/New_York')),
796 new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
799 new DateTime('2013-03-29', new DateTimeZone('America/New_York')),
800 new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
804 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
805 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/Chicago')),
808 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
809 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/Chicago')),
813 new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
814 new DateTime('2013-03-30', new DateTimeZone('America/Chicago')),
817 new DateTime('2013-03-29T05:13:35-0600'),
818 new DateTime('2013-03-29T04:13:35-0600'),
821 new DateTime('2013-03-29T05:13:35-0600'),
822 new DateTime('2013-03-29T05:13:35-0500'),
825 //array(new Exception('Exception 1'), new Exception('Exception 2')),
827 array(new SampleClass(4, 8, 15), false),
828 array(false, new SampleClass(4, 8, 15)),
829 array(array(0 => 1, 1 => 2), false),
830 array(false, array(0 => 1, 1 => 2)),
831 array(array(), new stdClass),
832 array(new stdClass, array()),
833 // PHP: 0 == 'Foobar' => true!
834 // We want these values to differ
842 protected function equalValues()
844 // cyclic dependencies
846 $book1->author = new Author('Terry Pratchett');
847 $book1->author->books[] = $book1;
849 $book2->author = new Author('Terry Pratchett');
850 $book2->author->books[] = $book2;
852 $object1 = new SampleClass(4, 8, 15);
853 $object2 = new SampleClass(4, 8, 15);
854 $storage1 = new SplObjectStorage;
855 $storage1->attach($object1);
856 $storage2 = new SplObjectStorage;
857 $storage2->attach($object1);
861 array('a', 'A', 0, false, true), // ignore case
863 array(array('a' => 1, 'b' => 2), array('b' => 2, 'a' => 1)),
864 array(array(1), array('1')),
865 array(array(3, 2, 1), array(2, 3, 1), 0, true), // canonicalized comparison
867 array(2.3, 2.5, 0.5),
868 array(array(2.3), array(2.5), 0.5),
869 array(array(array(2.3)), array(array(2.5)), 0.5),
870 array(new Struct(2.3), new Struct(2.5), 0.5),
871 array(array(new Struct(2.3)), array(new Struct(2.5)), 0.5),
872 // numeric with delta
875 array($object1, $object2),
876 array($book1, $book2),
878 array($storage1, $storage2),
881 PHPUnit_Util_XML::load('<root></root>'),
882 PHPUnit_Util_XML::load('<root/>'),
885 PHPUnit_Util_XML::load('<root attr="bar"></root>'),
886 PHPUnit_Util_XML::load('<root attr="bar"/>'),
889 PHPUnit_Util_XML::load('<root><foo attr="bar"></foo></root>'),
890 PHPUnit_Util_XML::load('<root><foo attr="bar"/></root>'),
893 PHPUnit_Util_XML::load("<root>\n <child/>\n</root>"),
894 PHPUnit_Util_XML::load('<root><child/></root>'),
897 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
898 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
901 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
902 new DateTime('2013-03-29 04:13:25', new DateTimeZone('America/New_York')),
906 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
907 new DateTime('2013-03-29 04:14:40', new DateTimeZone('America/New_York')),
911 new DateTime('2013-03-29', new DateTimeZone('America/New_York')),
912 new DateTime('2013-03-29', new DateTimeZone('America/New_York')),
915 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
916 new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/Chicago')),
919 new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
920 new DateTime('2013-03-29 03:13:49', new DateTimeZone('America/Chicago')),
924 new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
925 new DateTime('2013-03-29 23:00:00', new DateTimeZone('America/Chicago')),
928 new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
929 new DateTime('2013-03-29 23:01:30', new DateTimeZone('America/Chicago')),
933 new DateTime('@1364616000'),
934 new DateTime('2013-03-29 23:00:00', new DateTimeZone('America/Chicago')),
937 new DateTime('2013-03-29T05:13:35-0500'),
938 new DateTime('2013-03-29T04:13:35-0600'),
941 //array(new Exception('Exception 1'), new Exception('Exception 1')),
947 array((string) (1/3), 1 - 2/3),
948 array(1/3, (string) (1 - 2/3)),
949 array('string representation', new ClassWithToString),
950 array(new ClassWithToString, 'string representation'),
954 public function equalProvider()
957 return array_merge($this->equalValues(), $this->sameValues());
960 public function notEqualProvider()
962 return $this->notEqualValues();
965 public function sameProvider()
967 return $this->sameValues();
970 public function notSameProvider()
972 // not equal |= not same
973 // equal, ¬same |= not same
974 return array_merge($this->notEqualValues(), $this->equalValues());
978 * @covers PHPUnit_Framework_Assert::assertEquals
979 * @dataProvider equalProvider
981 public function testAssertEqualsSucceeds($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
983 $this->assertEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase);
987 * @covers PHPUnit_Framework_Assert::assertEquals
988 * @dataProvider notEqualProvider
990 public function testAssertEqualsFails($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
993 $this->assertEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase);
994 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1002 * @covers PHPUnit_Framework_Assert::assertNotEquals
1003 * @dataProvider notEqualProvider
1005 public function testAssertNotEqualsSucceeds($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
1007 $this->assertNotEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase);
1011 * @covers PHPUnit_Framework_Assert::assertNotEquals
1012 * @dataProvider equalProvider
1014 public function testAssertNotEqualsFails($a, $b, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
1017 $this->assertNotEquals($a, $b, '', $delta, 10, $canonicalize, $ignoreCase);
1018 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1026 * @covers PHPUnit_Framework_Assert::assertSame
1027 * @dataProvider sameProvider
1029 public function testAssertSameSucceeds($a, $b)
1031 $this->assertSame($a, $b);
1035 * @covers PHPUnit_Framework_Assert::assertSame
1036 * @dataProvider notSameProvider
1038 public function testAssertSameFails($a, $b)
1041 $this->assertSame($a, $b);
1042 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1050 * @covers PHPUnit_Framework_Assert::assertNotSame
1051 * @dataProvider notSameProvider
1053 public function testAssertNotSameSucceeds($a, $b)
1055 $this->assertNotSame($a, $b);
1059 * @covers PHPUnit_Framework_Assert::assertNotSame
1060 * @dataProvider sameProvider
1062 public function testAssertNotSameFails($a, $b)
1065 $this->assertNotSame($a, $b);
1066 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1074 * @covers PHPUnit_Framework_Assert::assertXmlFileEqualsXmlFile
1076 public function testAssertXmlFileEqualsXmlFile()
1078 $this->assertXmlFileEqualsXmlFile(
1079 $this->filesDirectory . 'foo.xml',
1080 $this->filesDirectory . 'foo.xml'
1084 $this->assertXmlFileEqualsXmlFile(
1085 $this->filesDirectory . 'foo.xml',
1086 $this->filesDirectory . 'bar.xml'
1088 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1096 * @covers PHPUnit_Framework_Assert::assertXmlFileNotEqualsXmlFile
1098 public function testAssertXmlFileNotEqualsXmlFile()
1100 $this->assertXmlFileNotEqualsXmlFile(
1101 $this->filesDirectory . 'foo.xml',
1102 $this->filesDirectory . 'bar.xml'
1106 $this->assertXmlFileNotEqualsXmlFile(
1107 $this->filesDirectory . 'foo.xml',
1108 $this->filesDirectory . 'foo.xml'
1110 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1118 * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile
1120 public function testAssertXmlStringEqualsXmlFile()
1122 $this->assertXmlStringEqualsXmlFile(
1123 $this->filesDirectory . 'foo.xml',
1124 file_get_contents($this->filesDirectory . 'foo.xml')
1128 $this->assertXmlStringEqualsXmlFile(
1129 $this->filesDirectory . 'foo.xml',
1130 file_get_contents($this->filesDirectory . 'bar.xml')
1132 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1140 * @covers PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlFile
1142 public function testXmlStringNotEqualsXmlFile()
1144 $this->assertXmlStringNotEqualsXmlFile(
1145 $this->filesDirectory . 'foo.xml',
1146 file_get_contents($this->filesDirectory . 'bar.xml')
1150 $this->assertXmlStringNotEqualsXmlFile(
1151 $this->filesDirectory . 'foo.xml',
1152 file_get_contents($this->filesDirectory . 'foo.xml')
1154 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1162 * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString
1164 public function testAssertXmlStringEqualsXmlString()
1166 $this->assertXmlStringEqualsXmlString('<root/>', '<root/>');
1169 $this->assertXmlStringEqualsXmlString('<foo/>', '<bar/>');
1170 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1178 * @expectedException PHPUnit_Framework_Exception
1179 * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString
1182 public function testAssertXmlStringEqualsXmlString2()
1184 $this->assertXmlStringEqualsXmlString('<a></b>', '<c></d>');
1188 * @covers PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString
1191 public function testAssertXmlStringEqualsXmlString3()
1194 <?xml version="1.0"?>
1201 <?xml version="1.0"?>
1207 $this->assertXmlStringEqualsXmlString($expected, $actual);
1211 * @covers PHPUnit_Framework_Assert::assertXmlStringNotEqualsXmlString
1213 public function testAssertXmlStringNotEqualsXmlString()
1215 $this->assertXmlStringNotEqualsXmlString('<foo/>', '<bar/>');
1218 $this->assertXmlStringNotEqualsXmlString('<root/>', '<root/>');
1219 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1227 * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure
1229 public function testXMLStructureIsSame()
1231 $expected = new DOMDocument;
1232 $expected->load($this->filesDirectory . 'structureExpected.xml');
1234 $actual = new DOMDocument;
1235 $actual->load($this->filesDirectory . 'structureExpected.xml');
1237 $this->assertEqualXMLStructure(
1238 $expected->firstChild, $actual->firstChild, true
1243 * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure
1244 * @expectedException PHPUnit_Framework_ExpectationFailedException
1246 public function testXMLStructureWrongNumberOfAttributes()
1248 $expected = new DOMDocument;
1249 $expected->load($this->filesDirectory . 'structureExpected.xml');
1251 $actual = new DOMDocument;
1252 $actual->load($this->filesDirectory . 'structureWrongNumberOfAttributes.xml');
1254 $this->assertEqualXMLStructure(
1255 $expected->firstChild, $actual->firstChild, true
1260 * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure
1261 * @expectedException PHPUnit_Framework_ExpectationFailedException
1263 public function testXMLStructureWrongNumberOfNodes()
1265 $expected = new DOMDocument;
1266 $expected->load($this->filesDirectory . 'structureExpected.xml');
1268 $actual = new DOMDocument;
1269 $actual->load($this->filesDirectory . 'structureWrongNumberOfNodes.xml');
1271 $this->assertEqualXMLStructure(
1272 $expected->firstChild, $actual->firstChild, true
1277 * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure
1279 public function testXMLStructureIsSameButDataIsNot()
1281 $expected = new DOMDocument;
1282 $expected->load($this->filesDirectory . 'structureExpected.xml');
1284 $actual = new DOMDocument;
1285 $actual->load($this->filesDirectory . 'structureIsSameButDataIsNot.xml');
1287 $this->assertEqualXMLStructure(
1288 $expected->firstChild, $actual->firstChild, true
1293 * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure
1295 public function testXMLStructureAttributesAreSameButValuesAreNot()
1297 $expected = new DOMDocument;
1298 $expected->load($this->filesDirectory . 'structureExpected.xml');
1300 $actual = new DOMDocument;
1301 $actual->load($this->filesDirectory . 'structureAttributesAreSameButValuesAreNot.xml');
1303 $this->assertEqualXMLStructure(
1304 $expected->firstChild, $actual->firstChild, true
1309 * @covers PHPUnit_Framework_Assert::assertEqualXMLStructure
1311 public function testXMLStructureIgnoreTextNodes()
1313 $expected = new DOMDocument;
1314 $expected->load($this->filesDirectory . 'structureExpected.xml');
1316 $actual = new DOMDocument;
1317 $actual->load($this->filesDirectory . 'structureIgnoreTextNodes.xml');
1319 $this->assertEqualXMLStructure(
1320 $expected->firstChild, $actual->firstChild, true
1325 * @covers PHPUnit_Framework_Assert::assertEquals
1327 public function testAssertStringEqualsNumeric()
1329 $this->assertEquals('0', 0);
1332 $this->assertEquals('0', 1);
1333 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1341 * @covers PHPUnit_Framework_Assert::assertNotEquals
1343 public function testAssertStringEqualsNumeric2()
1345 $this->assertNotEquals('A', 0);
1349 * @covers PHPUnit_Framework_Assert::assertFileExists
1350 * @expectedException PHPUnit_Framework_Exception
1352 public function testAssertFileExistsThrowsException()
1354 $this->assertFileExists(null);
1358 * @covers PHPUnit_Framework_Assert::assertFileExists
1360 public function testAssertFileExists()
1362 $this->assertFileExists(__FILE__);
1365 $this->assertFileExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting');
1366 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1374 * @covers PHPUnit_Framework_Assert::assertFileNotExists
1375 * @expectedException PHPUnit_Framework_Exception
1377 public function testAssertFileNotExistsThrowsException()
1379 $this->assertFileNotExists(null);
1383 * @covers PHPUnit_Framework_Assert::assertFileNotExists
1385 public function testAssertFileNotExists()
1387 $this->assertFileNotExists(__DIR__ . DIRECTORY_SEPARATOR . 'NotExisting');
1390 $this->assertFileNotExists(__FILE__);
1391 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1399 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
1401 public function testAssertObjectHasAttribute()
1403 $o = new Author('Terry Pratchett');
1405 $this->assertObjectHasAttribute('name', $o);
1408 $this->assertObjectHasAttribute('foo', $o);
1409 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1417 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
1419 public function testAssertObjectNotHasAttribute()
1421 $o = new Author('Terry Pratchett');
1423 $this->assertObjectNotHasAttribute('foo', $o);
1426 $this->assertObjectNotHasAttribute('name', $o);
1427 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1435 * @covers PHPUnit_Framework_Assert::assertNull
1437 public function testAssertNull()
1439 $this->assertNull(null);
1442 $this->assertNull(new stdClass);
1443 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1451 * @covers PHPUnit_Framework_Assert::assertNotNull
1453 public function testAssertNotNull()
1455 $this->assertNotNull(new stdClass);
1458 $this->assertNotNull(null);
1459 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1467 * @covers PHPUnit_Framework_Assert::assertTrue
1469 public function testAssertTrue()
1471 $this->assertTrue(true);
1474 $this->assertTrue(false);
1475 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1483 * @covers PHPUnit_Framework_Assert::assertNotTrue
1485 public function testAssertNotTrue()
1487 $this->assertNotTrue(false);
1488 $this->assertNotTrue(1);
1489 $this->assertNotTrue('true');
1492 $this->assertNotTrue(true);
1493 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1501 * @covers PHPUnit_Framework_Assert::assertFalse
1503 public function testAssertFalse()
1505 $this->assertFalse(false);
1508 $this->assertFalse(true);
1509 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1517 * @covers PHPUnit_Framework_Assert::assertNotFalse
1519 public function testAssertNotFalse()
1521 $this->assertNotFalse(true);
1522 $this->assertNotFalse(0);
1523 $this->assertNotFalse('');
1526 $this->assertNotFalse(false);
1527 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1535 * @covers PHPUnit_Framework_Assert::assertRegExp
1536 * @expectedException PHPUnit_Framework_Exception
1538 public function testAssertRegExpThrowsException()
1540 $this->assertRegExp(null, null);
1544 * @covers PHPUnit_Framework_Assert::assertRegExp
1545 * @expectedException PHPUnit_Framework_Exception
1547 public function testAssertRegExpThrowsException2()
1549 $this->assertRegExp('', null);
1553 * @covers PHPUnit_Framework_Assert::assertNotRegExp
1554 * @expectedException PHPUnit_Framework_Exception
1556 public function testAssertNotRegExpThrowsException()
1558 $this->assertNotRegExp(null, null);
1562 * @covers PHPUnit_Framework_Assert::assertNotRegExp
1563 * @expectedException PHPUnit_Framework_Exception
1565 public function testAssertNotRegExpThrowsException2()
1567 $this->assertNotRegExp('', null);
1571 * @covers PHPUnit_Framework_Assert::assertRegExp
1573 public function testAssertRegExp()
1575 $this->assertRegExp('/foo/', 'foobar');
1578 $this->assertRegExp('/foo/', 'bar');
1579 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1587 * @covers PHPUnit_Framework_Assert::assertNotRegExp
1589 public function testAssertNotRegExp()
1591 $this->assertNotRegExp('/foo/', 'bar');
1594 $this->assertNotRegExp('/foo/', 'foobar');
1595 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1603 * @covers PHPUnit_Framework_Assert::assertSame
1605 public function testAssertSame()
1609 $this->assertSame($o, $o);
1616 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1624 * @covers PHPUnit_Framework_Assert::assertSame
1626 public function testAssertSame2()
1628 $this->assertSame(true, true);
1629 $this->assertSame(false, false);
1632 $this->assertSame(true, false);
1633 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1641 * @covers PHPUnit_Framework_Assert::assertNotSame
1643 public function testAssertNotSame()
1645 $this->assertNotSame(
1650 $this->assertNotSame(
1655 $this->assertNotSame(
1663 $this->assertNotSame($o, $o);
1664 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1672 * @covers PHPUnit_Framework_Assert::assertNotSame
1674 public function testAssertNotSame2()
1676 $this->assertNotSame(true, false);
1677 $this->assertNotSame(false, true);
1680 $this->assertNotSame(true, true);
1681 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1689 * @covers PHPUnit_Framework_Assert::assertNotSame
1691 public function testAssertNotSameFailsNull()
1694 $this->assertNotSame(null, null);
1695 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1703 * @covers PHPUnit_Framework_Assert::assertGreaterThan
1705 public function testGreaterThan()
1707 $this->assertGreaterThan(1, 2);
1710 $this->assertGreaterThan(2, 1);
1711 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1719 * @covers PHPUnit_Framework_Assert::assertAttributeGreaterThan
1721 public function testAttributeGreaterThan()
1723 $this->assertAttributeGreaterThan(
1724 1, 'bar', new ClassWithNonPublicAttributes
1728 $this->assertAttributeGreaterThan(
1729 1, 'foo', new ClassWithNonPublicAttributes
1731 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1739 * @covers PHPUnit_Framework_Assert::assertGreaterThanOrEqual
1741 public function testGreaterThanOrEqual()
1743 $this->assertGreaterThanOrEqual(1, 2);
1746 $this->assertGreaterThanOrEqual(2, 1);
1747 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1755 * @covers PHPUnit_Framework_Assert::assertAttributeGreaterThanOrEqual
1757 public function testAttributeGreaterThanOrEqual()
1759 $this->assertAttributeGreaterThanOrEqual(
1760 1, 'bar', new ClassWithNonPublicAttributes
1764 $this->assertAttributeGreaterThanOrEqual(
1765 2, 'foo', new ClassWithNonPublicAttributes
1767 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1775 * @covers PHPUnit_Framework_Assert::assertLessThan
1777 public function testLessThan()
1779 $this->assertLessThan(2, 1);
1782 $this->assertLessThan(1, 2);
1783 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1791 * @covers PHPUnit_Framework_Assert::assertAttributeLessThan
1793 public function testAttributeLessThan()
1795 $this->assertAttributeLessThan(
1796 2, 'foo', new ClassWithNonPublicAttributes
1800 $this->assertAttributeLessThan(
1801 1, 'bar', new ClassWithNonPublicAttributes
1803 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1811 * @covers PHPUnit_Framework_Assert::assertLessThanOrEqual
1813 public function testLessThanOrEqual()
1815 $this->assertLessThanOrEqual(2, 1);
1818 $this->assertLessThanOrEqual(1, 2);
1819 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1827 * @covers PHPUnit_Framework_Assert::assertAttributeLessThanOrEqual
1829 public function testAttributeLessThanOrEqual()
1831 $this->assertAttributeLessThanOrEqual(
1832 2, 'foo', new ClassWithNonPublicAttributes
1836 $this->assertAttributeLessThanOrEqual(
1837 1, 'bar', new ClassWithNonPublicAttributes
1839 } catch (PHPUnit_Framework_AssertionFailedError $e) {
1847 * @covers PHPUnit_Framework_Assert::readAttribute
1848 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1849 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1851 public function testReadAttribute()
1853 $obj = new ClassWithNonPublicAttributes;
1855 $this->assertEquals('foo', $this->readAttribute($obj, 'publicAttribute'));
1856 $this->assertEquals('bar', $this->readAttribute($obj, 'protectedAttribute'));
1857 $this->assertEquals('baz', $this->readAttribute($obj, 'privateAttribute'));
1858 $this->assertEquals('bar', $this->readAttribute($obj, 'protectedParentAttribute'));
1859 //$this->assertEquals('bar', $this->readAttribute($obj, 'privateParentAttribute'));
1863 * @covers PHPUnit_Framework_Assert::readAttribute
1864 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1865 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1867 public function testReadAttribute2()
1869 $this->assertEquals('foo', $this->readAttribute('ClassWithNonPublicAttributes', 'publicStaticAttribute'));
1870 $this->assertEquals('bar', $this->readAttribute('ClassWithNonPublicAttributes', 'protectedStaticAttribute'));
1871 $this->assertEquals('baz', $this->readAttribute('ClassWithNonPublicAttributes', 'privateStaticAttribute'));
1872 $this->assertEquals('foo', $this->readAttribute('ClassWithNonPublicAttributes', 'protectedStaticParentAttribute'));
1873 $this->assertEquals('foo', $this->readAttribute('ClassWithNonPublicAttributes', 'privateStaticParentAttribute'));
1877 * @covers PHPUnit_Framework_Assert::readAttribute
1878 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1879 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1880 * @expectedException PHPUnit_Framework_Exception
1882 public function testReadAttribute3()
1884 $this->readAttribute('StdClass', null);
1888 * @covers PHPUnit_Framework_Assert::readAttribute
1889 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1890 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1891 * @expectedException PHPUnit_Framework_Exception
1893 public function testReadAttribute4()
1895 $this->readAttribute('NotExistingClass', 'foo');
1899 * @covers PHPUnit_Framework_Assert::readAttribute
1900 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1901 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1902 * @expectedException PHPUnit_Framework_Exception
1904 public function testReadAttribute5()
1906 $this->readAttribute(null, 'foo');
1910 * @covers PHPUnit_Framework_Assert::readAttribute
1911 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1912 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1913 * @expectedException PHPUnit_Framework_Exception
1915 public function testReadAttributeIfAttributeNameIsNotValid()
1917 $this->readAttribute('StdClass', '2');
1921 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1922 * @expectedException PHPUnit_Framework_Exception
1924 public function testGetStaticAttributeRaisesExceptionForInvalidFirstArgument()
1926 $this->getStaticAttribute(null, 'foo');
1930 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1931 * @expectedException PHPUnit_Framework_Exception
1933 public function testGetStaticAttributeRaisesExceptionForInvalidFirstArgument2()
1935 $this->getStaticAttribute('NotExistingClass', 'foo');
1939 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1940 * @expectedException PHPUnit_Framework_Exception
1942 public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument()
1944 $this->getStaticAttribute('stdClass', null);
1948 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1949 * @expectedException PHPUnit_Framework_Exception
1951 public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument2()
1953 $this->getStaticAttribute('stdClass', '0');
1957 * @covers PHPUnit_Framework_Assert::getStaticAttribute
1958 * @expectedException PHPUnit_Framework_Exception
1960 public function testGetStaticAttributeRaisesExceptionForInvalidSecondArgument3()
1962 $this->getStaticAttribute('stdClass', 'foo');
1966 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1967 * @expectedException PHPUnit_Framework_Exception
1969 public function testGetObjectAttributeRaisesExceptionForInvalidFirstArgument()
1971 $this->getObjectAttribute(null, 'foo');
1975 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1976 * @expectedException PHPUnit_Framework_Exception
1978 public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument()
1980 $this->getObjectAttribute(new stdClass, null);
1984 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1985 * @expectedException PHPUnit_Framework_Exception
1987 public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument2()
1989 $this->getObjectAttribute(new stdClass, '0');
1993 * @covers PHPUnit_Framework_Assert::getObjectAttribute
1994 * @expectedException PHPUnit_Framework_Exception
1996 public function testGetObjectAttributeRaisesExceptionForInvalidSecondArgument3()
1998 $this->getObjectAttribute(new stdClass, 'foo');
2002 * @covers PHPUnit_Framework_Assert::getObjectAttribute
2004 public function testGetObjectAttributeWorksForInheritedAttributes()
2006 $this->assertEquals(
2008 $this->getObjectAttribute(new ClassWithNonPublicAttributes, 'privateParentAttribute')
2013 * @covers PHPUnit_Framework_Assert::assertAttributeContains
2015 public function testAssertPublicAttributeContains()
2017 $obj = new ClassWithNonPublicAttributes;
2019 $this->assertAttributeContains('foo', 'publicArray', $obj);
2022 $this->assertAttributeContains('bar', 'publicArray', $obj);
2023 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2031 * @covers PHPUnit_Framework_Assert::assertAttributeContainsOnly
2033 public function testAssertPublicAttributeContainsOnly()
2035 $obj = new ClassWithNonPublicAttributes;
2037 $this->assertAttributeContainsOnly('string', 'publicArray', $obj);
2040 $this->assertAttributeContainsOnly('integer', 'publicArray', $obj);
2041 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2049 * @covers PHPUnit_Framework_Assert::assertAttributeNotContains
2051 public function testAssertPublicAttributeNotContains()
2053 $obj = new ClassWithNonPublicAttributes;
2055 $this->assertAttributeNotContains('bar', 'publicArray', $obj);
2058 $this->assertAttributeNotContains('foo', 'publicArray', $obj);
2059 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2067 * @covers PHPUnit_Framework_Assert::assertAttributeNotContainsOnly
2069 public function testAssertPublicAttributeNotContainsOnly()
2071 $obj = new ClassWithNonPublicAttributes;
2073 $this->assertAttributeNotContainsOnly('integer', 'publicArray', $obj);
2076 $this->assertAttributeNotContainsOnly('string', 'publicArray', $obj);
2077 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2085 * @covers PHPUnit_Framework_Assert::assertAttributeContains
2087 public function testAssertProtectedAttributeContains()
2089 $obj = new ClassWithNonPublicAttributes;
2091 $this->assertAttributeContains('bar', 'protectedArray', $obj);
2094 $this->assertAttributeContains('foo', 'protectedArray', $obj);
2095 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2103 * @covers PHPUnit_Framework_Assert::assertAttributeNotContains
2105 public function testAssertProtectedAttributeNotContains()
2107 $obj = new ClassWithNonPublicAttributes;
2109 $this->assertAttributeNotContains('foo', 'protectedArray', $obj);
2112 $this->assertAttributeNotContains('bar', 'protectedArray', $obj);
2113 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2121 * @covers PHPUnit_Framework_Assert::assertAttributeContains
2123 public function testAssertPrivateAttributeContains()
2125 $obj = new ClassWithNonPublicAttributes;
2127 $this->assertAttributeContains('baz', 'privateArray', $obj);
2130 $this->assertAttributeContains('foo', 'privateArray', $obj);
2131 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2139 * @covers PHPUnit_Framework_Assert::assertAttributeNotContains
2141 public function testAssertPrivateAttributeNotContains()
2143 $obj = new ClassWithNonPublicAttributes;
2145 $this->assertAttributeNotContains('foo', 'privateArray', $obj);
2148 $this->assertAttributeNotContains('baz', 'privateArray', $obj);
2149 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2157 * @covers PHPUnit_Framework_Assert::assertAttributeContains
2159 public function testAssertAttributeContainsNonObject()
2161 $obj = new ClassWithNonPublicAttributes;
2163 $this->assertAttributeContains(true, 'privateArray', $obj);
2166 $this->assertAttributeContains(true, 'privateArray', $obj, '', false, true, true);
2167 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2175 * @covers PHPUnit_Framework_Assert::assertAttributeNotContains
2177 public function testAssertAttributeNotContainsNonObject()
2179 $obj = new ClassWithNonPublicAttributes;
2181 $this->assertAttributeNotContains(true, 'privateArray', $obj, '', false, true, true);
2184 $this->assertAttributeNotContains(true, 'privateArray', $obj);
2185 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2193 * @covers PHPUnit_Framework_Assert::assertAttributeEquals
2195 public function testAssertPublicAttributeEquals()
2197 $obj = new ClassWithNonPublicAttributes;
2199 $this->assertAttributeEquals('foo', 'publicAttribute', $obj);
2202 $this->assertAttributeEquals('bar', 'publicAttribute', $obj);
2203 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2211 * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals
2213 public function testAssertPublicAttributeNotEquals()
2215 $obj = new ClassWithNonPublicAttributes;
2217 $this->assertAttributeNotEquals('bar', 'publicAttribute', $obj);
2220 $this->assertAttributeNotEquals('foo', 'publicAttribute', $obj);
2221 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2229 * @covers PHPUnit_Framework_Assert::assertAttributeSame
2231 public function testAssertPublicAttributeSame()
2233 $obj = new ClassWithNonPublicAttributes;
2235 $this->assertAttributeSame('foo', 'publicAttribute', $obj);
2238 $this->assertAttributeSame('bar', 'publicAttribute', $obj);
2239 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2247 * @covers PHPUnit_Framework_Assert::assertAttributeNotSame
2249 public function testAssertPublicAttributeNotSame()
2251 $obj = new ClassWithNonPublicAttributes;
2253 $this->assertAttributeNotSame('bar', 'publicAttribute', $obj);
2256 $this->assertAttributeNotSame('foo', 'publicAttribute', $obj);
2257 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2265 * @covers PHPUnit_Framework_Assert::assertAttributeEquals
2267 public function testAssertProtectedAttributeEquals()
2269 $obj = new ClassWithNonPublicAttributes;
2271 $this->assertAttributeEquals('bar', 'protectedAttribute', $obj);
2274 $this->assertAttributeEquals('foo', 'protectedAttribute', $obj);
2275 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2283 * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals
2285 public function testAssertProtectedAttributeNotEquals()
2287 $obj = new ClassWithNonPublicAttributes;
2289 $this->assertAttributeNotEquals('foo', 'protectedAttribute', $obj);
2292 $this->assertAttributeNotEquals('bar', 'protectedAttribute', $obj);
2293 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2301 * @covers PHPUnit_Framework_Assert::assertAttributeEquals
2303 public function testAssertPrivateAttributeEquals()
2305 $obj = new ClassWithNonPublicAttributes;
2307 $this->assertAttributeEquals('baz', 'privateAttribute', $obj);
2310 $this->assertAttributeEquals('foo', 'privateAttribute', $obj);
2311 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2319 * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals
2321 public function testAssertPrivateAttributeNotEquals()
2323 $obj = new ClassWithNonPublicAttributes;
2325 $this->assertAttributeNotEquals('foo', 'privateAttribute', $obj);
2328 $this->assertAttributeNotEquals('baz', 'privateAttribute', $obj);
2329 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2337 * @covers PHPUnit_Framework_Assert::assertAttributeEquals
2339 public function testAssertPublicStaticAttributeEquals()
2341 $this->assertAttributeEquals('foo', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2344 $this->assertAttributeEquals('bar', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2345 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2353 * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals
2355 public function testAssertPublicStaticAttributeNotEquals()
2357 $this->assertAttributeNotEquals('bar', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2360 $this->assertAttributeNotEquals('foo', 'publicStaticAttribute', 'ClassWithNonPublicAttributes');
2361 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2369 * @covers PHPUnit_Framework_Assert::assertAttributeEquals
2371 public function testAssertProtectedStaticAttributeEquals()
2373 $this->assertAttributeEquals('bar', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2376 $this->assertAttributeEquals('foo', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2377 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2385 * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals
2387 public function testAssertProtectedStaticAttributeNotEquals()
2389 $this->assertAttributeNotEquals('foo', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2392 $this->assertAttributeNotEquals('bar', 'protectedStaticAttribute', 'ClassWithNonPublicAttributes');
2393 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2401 * @covers PHPUnit_Framework_Assert::assertAttributeEquals
2403 public function testAssertPrivateStaticAttributeEquals()
2405 $this->assertAttributeEquals('baz', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2408 $this->assertAttributeEquals('foo', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2409 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2417 * @covers PHPUnit_Framework_Assert::assertAttributeNotEquals
2419 public function testAssertPrivateStaticAttributeNotEquals()
2421 $this->assertAttributeNotEquals('foo', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2424 $this->assertAttributeNotEquals('baz', 'privateStaticAttribute', 'ClassWithNonPublicAttributes');
2425 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2433 * @covers PHPUnit_Framework_Assert::assertClassHasAttribute
2434 * @expectedException PHPUnit_Framework_Exception
2436 public function testAssertClassHasAttributeThrowsException()
2438 $this->assertClassHasAttribute(null, null);
2442 * @covers PHPUnit_Framework_Assert::assertClassHasAttribute
2443 * @expectedException PHPUnit_Framework_Exception
2445 public function testAssertClassHasAttributeThrowsException2()
2447 $this->assertClassHasAttribute('foo', null);
2451 * @covers PHPUnit_Framework_Assert::assertClassHasAttribute
2452 * @expectedException PHPUnit_Framework_Exception
2454 public function testAssertClassHasAttributeThrowsExceptionIfAttributeNameIsNotValid()
2456 $this->assertClassHasAttribute('1', 'ClassWithNonPublicAttributes');
2460 * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute
2461 * @expectedException PHPUnit_Framework_Exception
2463 public function testAssertClassNotHasAttributeThrowsException()
2465 $this->assertClassNotHasAttribute(null, null);
2469 * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute
2470 * @expectedException PHPUnit_Framework_Exception
2472 public function testAssertClassNotHasAttributeThrowsException2()
2474 $this->assertClassNotHasAttribute('foo', null);
2478 * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute
2479 * @expectedException PHPUnit_Framework_Exception
2481 public function testAssertClassNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid()
2483 $this->assertClassNotHasAttribute('1', 'ClassWithNonPublicAttributes');
2487 * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute
2488 * @expectedException PHPUnit_Framework_Exception
2490 public function testAssertClassHasStaticAttributeThrowsException()
2492 $this->assertClassHasStaticAttribute(null, null);
2496 * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute
2497 * @expectedException PHPUnit_Framework_Exception
2499 public function testAssertClassHasStaticAttributeThrowsException2()
2501 $this->assertClassHasStaticAttribute('foo', null);
2505 * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute
2506 * @expectedException PHPUnit_Framework_Exception
2508 public function testAssertClassHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid()
2510 $this->assertClassHasStaticAttribute('1', 'ClassWithNonPublicAttributes');
2514 * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute
2515 * @expectedException PHPUnit_Framework_Exception
2517 public function testAssertClassNotHasStaticAttributeThrowsException()
2519 $this->assertClassNotHasStaticAttribute(null, null);
2523 * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute
2524 * @expectedException PHPUnit_Framework_Exception
2526 public function testAssertClassNotHasStaticAttributeThrowsException2()
2528 $this->assertClassNotHasStaticAttribute('foo', null);
2532 * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute
2533 * @expectedException PHPUnit_Framework_Exception
2535 public function testAssertClassNotHasStaticAttributeThrowsExceptionIfAttributeNameIsNotValid()
2537 $this->assertClassNotHasStaticAttribute('1', 'ClassWithNonPublicAttributes');
2541 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
2542 * @expectedException PHPUnit_Framework_Exception
2544 public function testAssertObjectHasAttributeThrowsException()
2546 $this->assertObjectHasAttribute(null, null);
2550 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
2551 * @expectedException PHPUnit_Framework_Exception
2553 public function testAssertObjectHasAttributeThrowsException2()
2555 $this->assertObjectHasAttribute('foo', null);
2559 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
2560 * @expectedException PHPUnit_Framework_Exception
2562 public function testAssertObjectHasAttributeThrowsExceptionIfAttributeNameIsNotValid()
2564 $this->assertObjectHasAttribute('1', 'ClassWithNonPublicAttributes');
2568 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
2569 * @expectedException PHPUnit_Framework_Exception
2571 public function testAssertObjectNotHasAttributeThrowsException()
2573 $this->assertObjectNotHasAttribute(null, null);
2577 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
2578 * @expectedException PHPUnit_Framework_Exception
2580 public function testAssertObjectNotHasAttributeThrowsException2()
2582 $this->assertObjectNotHasAttribute('foo', null);
2586 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
2587 * @expectedException PHPUnit_Framework_Exception
2589 public function testAssertObjectNotHasAttributeThrowsExceptionIfAttributeNameIsNotValid()
2591 $this->assertObjectNotHasAttribute('1', 'ClassWithNonPublicAttributes');
2595 * @covers PHPUnit_Framework_Assert::assertClassHasAttribute
2597 public function testClassHasPublicAttribute()
2599 $this->assertClassHasAttribute('publicAttribute', 'ClassWithNonPublicAttributes');
2602 $this->assertClassHasAttribute('attribute', 'ClassWithNonPublicAttributes');
2603 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2611 * @covers PHPUnit_Framework_Assert::assertClassNotHasAttribute
2613 public function testClassNotHasPublicAttribute()
2615 $this->assertClassNotHasAttribute('attribute', 'ClassWithNonPublicAttributes');
2618 $this->assertClassNotHasAttribute('publicAttribute', 'ClassWithNonPublicAttributes');
2619 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2627 * @covers PHPUnit_Framework_Assert::assertClassHasStaticAttribute
2629 public function testClassHasPublicStaticAttribute()
2631 $this->assertClassHasStaticAttribute('publicStaticAttribute', 'ClassWithNonPublicAttributes');
2634 $this->assertClassHasStaticAttribute('attribute', 'ClassWithNonPublicAttributes');
2635 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2643 * @covers PHPUnit_Framework_Assert::assertClassNotHasStaticAttribute
2645 public function testClassNotHasPublicStaticAttribute()
2647 $this->assertClassNotHasStaticAttribute('attribute', 'ClassWithNonPublicAttributes');
2650 $this->assertClassNotHasStaticAttribute('publicStaticAttribute', 'ClassWithNonPublicAttributes');
2651 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2659 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
2661 public function testObjectHasPublicAttribute()
2663 $obj = new ClassWithNonPublicAttributes;
2665 $this->assertObjectHasAttribute('publicAttribute', $obj);
2668 $this->assertObjectHasAttribute('attribute', $obj);
2669 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2677 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
2679 public function testObjectNotHasPublicAttribute()
2681 $obj = new ClassWithNonPublicAttributes;
2683 $this->assertObjectNotHasAttribute('attribute', $obj);
2686 $this->assertObjectNotHasAttribute('publicAttribute', $obj);
2687 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2695 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
2697 public function testObjectHasOnTheFlyAttribute()
2699 $obj = new stdClass;
2702 $this->assertObjectHasAttribute('foo', $obj);
2705 $this->assertObjectHasAttribute('bar', $obj);
2706 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2714 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
2716 public function testObjectNotHasOnTheFlyAttribute()
2718 $obj = new stdClass;
2721 $this->assertObjectNotHasAttribute('bar', $obj);
2724 $this->assertObjectNotHasAttribute('foo', $obj);
2725 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2733 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
2735 public function testObjectHasProtectedAttribute()
2737 $obj = new ClassWithNonPublicAttributes;
2739 $this->assertObjectHasAttribute('protectedAttribute', $obj);
2742 $this->assertObjectHasAttribute('attribute', $obj);
2743 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2751 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
2753 public function testObjectNotHasProtectedAttribute()
2755 $obj = new ClassWithNonPublicAttributes;
2757 $this->assertObjectNotHasAttribute('attribute', $obj);
2760 $this->assertObjectNotHasAttribute('protectedAttribute', $obj);
2761 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2769 * @covers PHPUnit_Framework_Assert::assertObjectHasAttribute
2771 public function testObjectHasPrivateAttribute()
2773 $obj = new ClassWithNonPublicAttributes;
2775 $this->assertObjectHasAttribute('privateAttribute', $obj);
2778 $this->assertObjectHasAttribute('attribute', $obj);
2779 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2787 * @covers PHPUnit_Framework_Assert::assertObjectNotHasAttribute
2789 public function testObjectNotHasPrivateAttribute()
2791 $obj = new ClassWithNonPublicAttributes;
2793 $this->assertObjectNotHasAttribute('attribute', $obj);
2796 $this->assertObjectNotHasAttribute('privateAttribute', $obj);
2797 } catch (PHPUnit_Framework_AssertionFailedError $e) {
2805 * @covers PHPUnit_Framework_Assert::assertThat
2806 * @covers PHPUnit_Framework_Assert::attribute
2807 * @covers PHPUnit_Framework_Assert::equalTo
2809 public function testAssertThatAttributeEquals()
2812 new ClassWithNonPublicAttributes,
2814 $this->equalTo('foo'),
2821 * @covers PHPUnit_Framework_Assert::assertThat
2822 * @covers PHPUnit_Framework_Assert::attribute
2823 * @covers PHPUnit_Framework_Assert::equalTo
2824 * @expectedException PHPUnit_Framework_AssertionFailedError
2826 public function testAssertThatAttributeEquals2()
2829 new ClassWithNonPublicAttributes,
2831 $this->equalTo('bar'),
2838 * @covers PHPUnit_Framework_Assert::assertThat
2839 * @covers PHPUnit_Framework_Assert::attribute
2840 * @covers PHPUnit_Framework_Assert::equalTo
2842 public function testAssertThatAttributeEqualTo()
2845 new ClassWithNonPublicAttributes,
2846 $this->attributeEqualTo('publicAttribute', 'foo')
2851 * @covers PHPUnit_Framework_Assert::assertThat
2852 * @covers PHPUnit_Framework_Assert::anything
2854 public function testAssertThatAnything()
2856 $this->assertThat('anything', $this->anything());
2860 * @covers PHPUnit_Framework_Assert::assertThat
2861 * @covers PHPUnit_Framework_Assert::isTrue
2863 public function testAssertThatIsTrue()
2865 $this->assertThat(true, $this->isTrue());
2869 * @covers PHPUnit_Framework_Assert::assertThat
2870 * @covers PHPUnit_Framework_Assert::isFalse
2872 public function testAssertThatIsFalse()
2874 $this->assertThat(false, $this->isFalse());
2878 * @covers PHPUnit_Framework_Assert::assertThat
2879 * @covers PHPUnit_Framework_Assert::isJson
2881 public function testAssertThatIsJson()
2883 $this->assertThat('{}', $this->isJson());
2887 * @covers PHPUnit_Framework_Assert::assertThat
2888 * @covers PHPUnit_Framework_Assert::anything
2889 * @covers PHPUnit_Framework_Assert::logicalAnd
2891 public function testAssertThatAnythingAndAnything()
2896 $this->anything(), $this->anything()
2902 * @covers PHPUnit_Framework_Assert::assertThat
2903 * @covers PHPUnit_Framework_Assert::anything
2904 * @covers PHPUnit_Framework_Assert::logicalOr
2906 public function testAssertThatAnythingOrAnything()
2911 $this->anything(), $this->anything()
2917 * @covers PHPUnit_Framework_Assert::assertThat
2918 * @covers PHPUnit_Framework_Assert::anything
2919 * @covers PHPUnit_Framework_Assert::logicalNot
2920 * @covers PHPUnit_Framework_Assert::logicalXor
2922 public function testAssertThatAnythingXorNotAnything()
2928 $this->logicalNot($this->anything())
2934 * @covers PHPUnit_Framework_Assert::assertThat
2935 * @covers PHPUnit_Framework_Assert::contains
2937 public function testAssertThatContains()
2939 $this->assertThat(array('foo'), $this->contains('foo'));
2943 * @covers PHPUnit_Framework_Assert::assertThat
2944 * @covers PHPUnit_Framework_Assert::stringContains
2946 public function testAssertThatStringContains()
2948 $this->assertThat('barfoobar', $this->stringContains('foo'));
2952 * @covers PHPUnit_Framework_Assert::assertThat
2953 * @covers PHPUnit_Framework_Assert::containsOnly
2955 public function testAssertThatContainsOnly()
2957 $this->assertThat(array('foo'), $this->containsOnly('string'));
2960 * @covers PHPUnit_Framework_Assert::assertThat
2961 * @covers PHPUnit_Framework_Assert::containsOnlyInstancesOf
2963 public function testAssertThatContainsOnlyInstancesOf()
2965 $this->assertThat(array(new Book), $this->containsOnlyInstancesOf('Book'));
2969 * @covers PHPUnit_Framework_Assert::assertThat
2970 * @covers PHPUnit_Framework_Assert::arrayHasKey
2972 public function testAssertThatArrayHasKey()
2974 $this->assertThat(array('foo' => 'bar'), $this->arrayHasKey('foo'));
2978 * @covers PHPUnit_Framework_Assert::assertThat
2979 * @covers PHPUnit_Framework_Assert::classHasAttribute
2981 public function testAssertThatClassHasAttribute()
2984 new ClassWithNonPublicAttributes,
2985 $this->classHasAttribute('publicAttribute')
2990 * @covers PHPUnit_Framework_Assert::assertThat
2991 * @covers PHPUnit_Framework_Assert::classHasStaticAttribute
2993 public function testAssertThatClassHasStaticAttribute()
2996 new ClassWithNonPublicAttributes,
2997 $this->classHasStaticAttribute('publicStaticAttribute')
3002 * @covers PHPUnit_Framework_Assert::assertThat
3003 * @covers PHPUnit_Framework_Assert::objectHasAttribute
3005 public function testAssertThatObjectHasAttribute()
3008 new ClassWithNonPublicAttributes,
3009 $this->objectHasAttribute('publicAttribute')
3014 * @covers PHPUnit_Framework_Assert::assertThat
3015 * @covers PHPUnit_Framework_Assert::equalTo
3017 public function testAssertThatEqualTo()
3019 $this->assertThat('foo', $this->equalTo('foo'));
3023 * @covers PHPUnit_Framework_Assert::assertThat
3024 * @covers PHPUnit_Framework_Assert::identicalTo
3026 public function testAssertThatIdenticalTo()
3028 $value = new stdClass;
3029 $constraint = $this->identicalTo($value);
3031 $this->assertThat($value, $constraint);
3035 * @covers PHPUnit_Framework_Assert::assertThat
3036 * @covers PHPUnit_Framework_Assert::isInstanceOf
3038 public function testAssertThatIsInstanceOf()
3040 $this->assertThat(new stdClass, $this->isInstanceOf('StdClass'));
3044 * @covers PHPUnit_Framework_Assert::assertThat
3045 * @covers PHPUnit_Framework_Assert::isType
3047 public function testAssertThatIsType()
3049 $this->assertThat('string', $this->isType('string'));
3053 * @covers PHPUnit_Framework_Assert::assertThat
3054 * @covers PHPUnit_Framework_Assert::isEmpty
3056 public function testAssertThatIsEmpty()
3058 $this->assertThat(array(), $this->isEmpty());
3062 * @covers PHPUnit_Framework_Assert::assertThat
3063 * @covers PHPUnit_Framework_Assert::fileExists
3065 public function testAssertThatFileExists()
3067 $this->assertThat(__FILE__, $this->fileExists());
3071 * @covers PHPUnit_Framework_Assert::assertThat
3072 * @covers PHPUnit_Framework_Assert::greaterThan
3074 public function testAssertThatGreaterThan()
3076 $this->assertThat(2, $this->greaterThan(1));
3080 * @covers PHPUnit_Framework_Assert::assertThat
3081 * @covers PHPUnit_Framework_Assert::greaterThanOrEqual
3083 public function testAssertThatGreaterThanOrEqual()
3085 $this->assertThat(2, $this->greaterThanOrEqual(1));
3089 * @covers PHPUnit_Framework_Assert::assertThat
3090 * @covers PHPUnit_Framework_Assert::lessThan
3092 public function testAssertThatLessThan()
3094 $this->assertThat(1, $this->lessThan(2));
3098 * @covers PHPUnit_Framework_Assert::assertThat
3099 * @covers PHPUnit_Framework_Assert::lessThanOrEqual
3101 public function testAssertThatLessThanOrEqual()
3103 $this->assertThat(1, $this->lessThanOrEqual(2));
3107 * @covers PHPUnit_Framework_Assert::assertThat
3108 * @covers PHPUnit_Framework_Assert::matchesRegularExpression
3110 public function testAssertThatMatchesRegularExpression()
3112 $this->assertThat('foobar', $this->matchesRegularExpression('/foo/'));
3116 * @covers PHPUnit_Framework_Assert::assertThat
3117 * @covers PHPUnit_Framework_Assert::callback
3119 public function testAssertThatCallback()
3123 $this->callback(function ($other) { return true; })
3128 * @covers PHPUnit_Framework_Assert::assertThat
3129 * @covers PHPUnit_Framework_Assert::countOf
3131 public function testAssertThatCountOf()
3133 $this->assertThat(array(1), $this->countOf(1));
3137 * @covers PHPUnit_Framework_Assert::assertFileEquals
3139 public function testAssertFileEquals()
3141 $this->assertFileEquals(
3142 $this->filesDirectory . 'foo.xml',
3143 $this->filesDirectory . 'foo.xml'
3147 $this->assertFileEquals(
3148 $this->filesDirectory . 'foo.xml',
3149 $this->filesDirectory . 'bar.xml'
3151 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3159 * @covers PHPUnit_Framework_Assert::assertFileNotEquals
3161 public function testAssertFileNotEquals()
3163 $this->assertFileNotEquals(
3164 $this->filesDirectory . 'foo.xml',
3165 $this->filesDirectory . 'bar.xml'
3169 $this->assertFileNotEquals(
3170 $this->filesDirectory . 'foo.xml',
3171 $this->filesDirectory . 'foo.xml'
3173 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3181 * @covers PHPUnit_Framework_Assert::assertStringEqualsFile
3183 public function testAssertStringEqualsFile()
3185 $this->assertStringEqualsFile(
3186 $this->filesDirectory . 'foo.xml',
3187 file_get_contents($this->filesDirectory . 'foo.xml')
3191 $this->assertStringEqualsFile(
3192 $this->filesDirectory . 'foo.xml',
3193 file_get_contents($this->filesDirectory . 'bar.xml')
3195 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3203 * @covers PHPUnit_Framework_Assert::assertStringNotEqualsFile
3205 public function testAssertStringNotEqualsFile()
3207 $this->assertStringNotEqualsFile(
3208 $this->filesDirectory . 'foo.xml',
3209 file_get_contents($this->filesDirectory . 'bar.xml')
3213 $this->assertStringNotEqualsFile(
3214 $this->filesDirectory . 'foo.xml',
3215 file_get_contents($this->filesDirectory . 'foo.xml')
3217 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3225 * @covers PHPUnit_Framework_Assert::assertStringStartsWith
3226 * @expectedException PHPUnit_Framework_Exception
3228 public function testAssertStringStartsWithThrowsException()
3230 $this->assertStringStartsWith(null, null);
3234 * @covers PHPUnit_Framework_Assert::assertStringStartsWith
3235 * @expectedException PHPUnit_Framework_Exception
3237 public function testAssertStringStartsWithThrowsException2()
3239 $this->assertStringStartsWith('', null);
3243 * @covers PHPUnit_Framework_Assert::assertStringStartsNotWith
3244 * @expectedException PHPUnit_Framework_Exception
3246 public function testAssertStringStartsNotWithThrowsException()
3248 $this->assertStringStartsNotWith(null, null);
3252 * @covers PHPUnit_Framework_Assert::assertStringStartsNotWith
3253 * @expectedException PHPUnit_Framework_Exception
3255 public function testAssertStringStartsNotWithThrowsException2()
3257 $this->assertStringStartsNotWith('', null);
3261 * @covers PHPUnit_Framework_Assert::assertStringEndsWith
3262 * @expectedException PHPUnit_Framework_Exception
3264 public function testAssertStringEndsWithThrowsException()
3266 $this->assertStringEndsWith(null, null);
3270 * @covers PHPUnit_Framework_Assert::assertStringEndsWith
3271 * @expectedException PHPUnit_Framework_Exception
3273 public function testAssertStringEndsWithThrowsException2()
3275 $this->assertStringEndsWith('', null);
3279 * @covers PHPUnit_Framework_Assert::assertStringEndsNotWith
3280 * @expectedException PHPUnit_Framework_Exception
3282 public function testAssertStringEndsNotWithThrowsException()
3284 $this->assertStringEndsNotWith(null, null);
3288 * @covers PHPUnit_Framework_Assert::assertStringEndsNotWith
3289 * @expectedException PHPUnit_Framework_Exception
3291 public function testAssertStringEndsNotWithThrowsException2()
3293 $this->assertStringEndsNotWith('', null);
3297 * @covers PHPUnit_Framework_Assert::assertStringStartsWith
3299 public function testAssertStringStartsWith()
3301 $this->assertStringStartsWith('prefix', 'prefixfoo');
3304 $this->assertStringStartsWith('prefix', 'foo');
3305 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3313 * @covers PHPUnit_Framework_Assert::assertStringStartsNotWith
3315 public function testAssertStringStartsNotWith()
3317 $this->assertStringStartsNotWith('prefix', 'foo');
3320 $this->assertStringStartsNotWith('prefix', 'prefixfoo');
3321 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3329 * @covers PHPUnit_Framework_Assert::assertStringEndsWith
3331 public function testAssertStringEndsWith()
3333 $this->assertStringEndsWith('suffix', 'foosuffix');
3336 $this->assertStringEndsWith('suffix', 'foo');
3337 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3345 * @covers PHPUnit_Framework_Assert::assertStringEndsNotWith
3347 public function testAssertStringEndsNotWith()
3349 $this->assertStringEndsNotWith('suffix', 'foo');
3352 $this->assertStringEndsNotWith('suffix', 'foosuffix');
3353 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3361 * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat
3362 * @expectedException PHPUnit_Framework_Exception
3364 public function testAssertStringMatchesFormatRaisesExceptionForInvalidFirstArgument()
3366 $this->assertStringMatchesFormat(null, '');
3370 * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat
3371 * @expectedException PHPUnit_Framework_Exception
3373 public function testAssertStringMatchesFormatRaisesExceptionForInvalidSecondArgument()
3375 $this->assertStringMatchesFormat('', null);
3379 * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat
3381 public function testAssertStringMatchesFormat()
3383 $this->assertStringMatchesFormat('*%s*', '***');
3387 * @covers PHPUnit_Framework_Assert::assertStringMatchesFormat
3388 * @expectedException PHPUnit_Framework_AssertionFailedError
3390 public function testAssertStringMatchesFormatFailure()
3392 $this->assertStringMatchesFormat('*%s*', '**');
3396 * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormat
3397 * @expectedException PHPUnit_Framework_Exception
3399 public function testAssertStringNotMatchesFormatRaisesExceptionForInvalidFirstArgument()
3401 $this->assertStringNotMatchesFormat(null, '');
3405 * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormat
3406 * @expectedException PHPUnit_Framework_Exception
3408 public function testAssertStringNotMatchesFormatRaisesExceptionForInvalidSecondArgument()
3410 $this->assertStringNotMatchesFormat('', null);
3414 * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormat
3416 public function testAssertStringNotMatchesFormat()
3418 $this->assertStringNotMatchesFormat('*%s*', '**');
3421 $this->assertStringMatchesFormat('*%s*', '**');
3422 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3430 * @covers PHPUnit_Framework_Assert::assertEmpty
3432 public function testAssertEmpty()
3434 $this->assertEmpty(array());
3437 $this->assertEmpty(array('foo'));
3438 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3446 * @covers PHPUnit_Framework_Assert::assertNotEmpty
3448 public function testAssertNotEmpty()
3450 $this->assertNotEmpty(array('foo'));
3453 $this->assertNotEmpty(array());
3454 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3462 * @covers PHPUnit_Framework_Assert::assertAttributeEmpty
3464 public function testAssertAttributeEmpty()
3469 $this->assertAttributeEmpty('a', $o);
3473 $this->assertAttributeEmpty('a', $o);
3474 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3482 * @covers PHPUnit_Framework_Assert::assertAttributeNotEmpty
3484 public function testAssertAttributeNotEmpty()
3489 $this->assertAttributeNotEmpty('a', $o);
3493 $this->assertAttributeNotEmpty('a', $o);
3494 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3502 * @covers PHPUnit_Framework_Assert::markTestIncomplete
3504 public function testMarkTestIncomplete()
3507 $this->markTestIncomplete('incomplete');
3508 } catch (PHPUnit_Framework_IncompleteTestError $e) {
3509 $this->assertEquals('incomplete', $e->getMessage());
3518 * @covers PHPUnit_Framework_Assert::markTestSkipped
3520 public function testMarkTestSkipped()
3523 $this->markTestSkipped('skipped');
3524 } catch (PHPUnit_Framework_SkippedTestError $e) {
3525 $this->assertEquals('skipped', $e->getMessage());
3534 * @covers PHPUnit_Framework_Assert::assertCount
3536 public function testAssertCount()
3538 $this->assertCount(2, array(1, 2));
3541 $this->assertCount(2, array(1, 2, 3));
3542 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3550 * @covers PHPUnit_Framework_Assert::assertCount
3552 public function testAssertCountTraversable()
3554 $this->assertCount(2, new ArrayIterator(array(1, 2)));
3557 $this->assertCount(2, new ArrayIterator(array(1, 2, 3)));
3558 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3566 * @covers PHPUnit_Framework_Assert::assertCount
3568 public function testAssertCountThrowsExceptionIfExpectedCountIsNoInteger()
3571 $this->assertCount('a', array());
3572 } catch (PHPUnit_Framework_Exception $e) {
3573 $this->assertEquals('Argument #1 (No Value) of PHPUnit_Framework_Assert::assertCount() must be a integer', $e->getMessage());
3582 * @covers PHPUnit_Framework_Assert::assertCount
3584 public function testAssertCountThrowsExceptionIfElementIsNotCountable()
3587 $this->assertCount(2, '');
3588 } catch (PHPUnit_Framework_Exception $e) {
3589 $this->assertEquals('Argument #2 (No Value) of PHPUnit_Framework_Assert::assertCount() must be a countable or traversable', $e->getMessage());
3598 * @covers PHPUnit_Framework_Assert::assertAttributeCount
3600 public function testAssertAttributeCount()
3605 $this->assertAttributeCount(0, 'a', $o);
3609 * @covers PHPUnit_Framework_Assert::assertNotCount
3611 public function testAssertNotCount()
3613 $this->assertNotCount(2, array(1, 2, 3));
3616 $this->assertNotCount(2, array(1, 2));
3617 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3625 * @covers PHPUnit_Framework_Assert::assertNotCount
3626 * @expectedException PHPUnit_Framework_Exception
3628 public function testAssertNotCountThrowsExceptionIfExpectedCountIsNoInteger()
3630 $this->assertNotCount('a', array());
3634 * @covers PHPUnit_Framework_Assert::assertNotCount
3635 * @expectedException PHPUnit_Framework_Exception
3637 public function testAssertNotCountThrowsExceptionIfElementIsNotCountable()
3639 $this->assertNotCount(2, '');
3643 * @covers PHPUnit_Framework_Assert::assertAttributeNotCount
3645 public function testAssertAttributeNotCount()
3650 $this->assertAttributeNotCount(1, 'a', $o);
3654 * @covers PHPUnit_Framework_Assert::assertSameSize
3656 public function testAssertSameSize()
3658 $this->assertSameSize(array(1, 2), array(3, 4));
3661 $this->assertSameSize(array(1, 2), array(1, 2, 3));
3662 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3670 * @covers PHPUnit_Framework_Assert::assertSameSize
3672 public function testAssertSameSizeThrowsExceptionIfExpectedIsNotCountable()
3675 $this->assertSameSize('a', array());
3676 } catch (PHPUnit_Framework_Exception $e) {
3677 $this->assertEquals('Argument #1 (No Value) of PHPUnit_Framework_Assert::assertSameSize() must be a countable or traversable', $e->getMessage());
3686 * @covers PHPUnit_Framework_Assert::assertSameSize
3688 public function testAssertSameSizeThrowsExceptionIfActualIsNotCountable()
3691 $this->assertSameSize(array(), '');
3692 } catch (PHPUnit_Framework_Exception $e) {
3693 $this->assertEquals('Argument #2 (No Value) of PHPUnit_Framework_Assert::assertSameSize() must be a countable or traversable', $e->getMessage());
3702 * @covers PHPUnit_Framework_Assert::assertNotSameSize
3704 public function testAssertNotSameSize()
3706 $this->assertNotSameSize(array(1, 2), array(1, 2, 3));
3709 $this->assertNotSameSize(array(1, 2), array(3, 4));
3710 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3718 * @covers PHPUnit_Framework_Assert::assertNotSameSize
3719 * @expectedException PHPUnit_Framework_Exception
3721 public function testAssertNotSameSizeThrowsExceptionIfExpectedIsNotCountable()
3723 $this->assertNotSameSize('a', array());
3727 * @covers PHPUnit_Framework_Assert::assertNotSameSize
3728 * @expectedException PHPUnit_Framework_Exception
3730 public function testAssertNotSameSizeThrowsExceptionIfActualIsNotCountable()
3732 $this->assertNotSameSize(array(), '');
3736 * @covers PHPUnit_Framework_Assert::assertJson
3737 * @expectedException PHPUnit_Framework_Exception
3739 public function testAssertJsonRaisesExceptionForInvalidArgument()
3741 $this->assertJson(null);
3745 * @covers PHPUnit_Framework_Assert::assertJson
3747 public function testAssertJson()
3749 $this->assertJson('{}');
3753 * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString
3755 public function testAssertJsonStringEqualsJsonString()
3757 $expected = '{"Mascott" : "Tux"}';
3758 $actual = '{"Mascott" : "Tux"}';
3759 $message = 'Given Json strings do not match';
3761 $this->assertJsonStringEqualsJsonString($expected, $actual, $message);
3765 * @dataProvider validInvalidJsonDataprovider
3766 * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString
3768 public function testAssertJsonStringEqualsJsonStringErrorRaised($expected, $actual)
3771 $this->assertJsonStringEqualsJsonString($expected, $actual);
3772 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3775 $this->fail('Expected exception not found');
3779 * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonString
3781 public function testAssertJsonStringNotEqualsJsonString()
3783 $expected = '{"Mascott" : "Beastie"}';
3784 $actual = '{"Mascott" : "Tux"}';
3785 $message = 'Given Json strings do match';
3787 $this->assertJsonStringNotEqualsJsonString($expected, $actual, $message);
3791 * @dataProvider validInvalidJsonDataprovider
3792 * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonString
3794 public function testAssertJsonStringNotEqualsJsonStringErrorRaised($expected, $actual)
3797 $this->assertJsonStringNotEqualsJsonString($expected, $actual);
3798 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3801 $this->fail('Expected exception not found');
3805 * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile
3807 public function testAssertJsonStringEqualsJsonFile()
3809 $file = __DIR__ . '/../_files/JsonData/simpleObject.json';
3810 $actual = json_encode(array('Mascott' => 'Tux'));
3812 $this->assertJsonStringEqualsJsonFile($file, $actual, $message);
3816 * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile
3818 public function testAssertJsonStringEqualsJsonFileExpectingExpectationFailedException()
3820 $file = __DIR__ . '/../_files/JsonData/simpleObject.json';
3821 $actual = json_encode(array('Mascott' => 'Beastie'));
3824 $this->assertJsonStringEqualsJsonFile($file, $actual, $message);
3825 } catch (PHPUnit_Framework_ExpectationFailedException $e) {
3826 $this->assertEquals(
3827 'Failed asserting that \'{"Mascott":"Beastie"}\' matches JSON string "{"Mascott":"Tux"}".',
3834 $this->fail('Expected Exception not thrown.');
3838 * @covers PHPUnit_Framework_Assert::assertJsonStringEqualsJsonFile
3840 public function testAssertJsonStringEqualsJsonFileExpectingException()
3842 $file = __DIR__ . '/../_files/JsonData/simpleObject.json';
3844 $this->assertJsonStringEqualsJsonFile($file, null);
3845 } catch (PHPUnit_Framework_Exception $e) {
3848 $this->fail('Expected Exception not thrown.');
3852 * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonFile
3854 public function testAssertJsonStringNotEqualsJsonFile()
3856 $file = __DIR__ . '/../_files/JsonData/simpleObject.json';
3857 $actual = json_encode(array('Mascott' => 'Beastie'));
3859 $this->assertJsonStringNotEqualsJsonFile($file, $actual, $message);
3863 * @covers PHPUnit_Framework_Assert::assertJsonStringNotEqualsJsonFile
3865 public function testAssertJsonStringNotEqualsJsonFileExpectingException()
3867 $file = __DIR__ . '/../_files/JsonData/simpleObject.json';
3869 $this->assertJsonStringNotEqualsJsonFile($file, null);
3870 } catch (PHPUnit_Framework_Exception $e) {
3873 $this->fail('Expected exception not found.');
3877 * @covers PHPUnit_Framework_Assert::assertJsonFileNotEqualsJsonFile
3879 public function testAssertJsonFileNotEqualsJsonFile()
3881 $fileExpected = __DIR__ . '/../_files/JsonData/simpleObject.json';
3882 $fileActual = __DIR__ . '/../_files/JsonData/arrayObject.json';
3884 $this->assertJsonFileNotEqualsJsonFile($fileExpected, $fileActual, $message);
3888 * @covers PHPUnit_Framework_Assert::assertJsonFileEqualsJsonFile
3890 public function testAssertJsonFileEqualsJsonFile()
3892 $file = __DIR__ . '/../_files/JsonData/simpleObject.json';
3894 $this->assertJsonFileEqualsJsonFile($file, $file, $message);
3898 * @covers PHPUnit_Framework_Assert::assertInstanceOf
3900 public function testAssertInstanceOf()
3902 $this->assertInstanceOf('stdClass', new stdClass);
3905 $this->assertInstanceOf('Exception', new stdClass);
3906 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3914 * @covers PHPUnit_Framework_Assert::assertInstanceOf
3915 * @expectedException PHPUnit_Framework_Exception
3917 public function testAssertInstanceOfThrowsExceptionForInvalidArgument()
3919 $this->assertInstanceOf(null, new stdClass);
3923 * @covers PHPUnit_Framework_Assert::assertAttributeInstanceOf
3925 public function testAssertAttributeInstanceOf()
3928 $o->a = new stdClass;
3930 $this->assertAttributeInstanceOf('stdClass', 'a', $o);
3934 * @covers PHPUnit_Framework_Assert::assertNotInstanceOf
3936 public function testAssertNotInstanceOf()
3938 $this->assertNotInstanceOf('Exception', new stdClass);
3941 $this->assertNotInstanceOf('stdClass', new stdClass);
3942 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3950 * @covers PHPUnit_Framework_Assert::assertNotInstanceOf
3951 * @expectedException PHPUnit_Framework_Exception
3953 public function testAssertNotInstanceOfThrowsExceptionForInvalidArgument()
3955 $this->assertNotInstanceOf(null, new stdClass);
3959 * @covers PHPUnit_Framework_Assert::assertAttributeNotInstanceOf
3961 public function testAssertAttributeNotInstanceOf()
3964 $o->a = new stdClass;
3966 $this->assertAttributeNotInstanceOf('Exception', 'a', $o);
3970 * @covers PHPUnit_Framework_Assert::assertInternalType
3972 public function testAssertInternalType()
3974 $this->assertInternalType('integer', 1);
3977 $this->assertInternalType('string', 1);
3978 } catch (PHPUnit_Framework_AssertionFailedError $e) {
3986 * @covers PHPUnit_Framework_Assert::assertInternalType
3988 public function testAssertInternalTypeDouble()
3990 $this->assertInternalType('double', 1.0);
3993 $this->assertInternalType('double', 1);
3994 } catch (PHPUnit_Framework_AssertionFailedError $e) {
4002 * @covers PHPUnit_Framework_Assert::assertInternalType
4003 * @expectedException PHPUnit_Framework_Exception
4005 public function testAssertInternalTypeThrowsExceptionForInvalidArgument()
4007 $this->assertInternalType(null, 1);
4011 * @covers PHPUnit_Framework_Assert::assertAttributeInternalType
4013 public function testAssertAttributeInternalType()
4018 $this->assertAttributeInternalType('integer', 'a', $o);
4022 * @covers PHPUnit_Framework_Assert::assertNotInternalType
4024 public function testAssertNotInternalType()
4026 $this->assertNotInternalType('string', 1);
4029 $this->assertNotInternalType('integer', 1);
4030 } catch (PHPUnit_Framework_AssertionFailedError $e) {
4038 * @covers PHPUnit_Framework_Assert::assertNotInternalType
4039 * @expectedException PHPUnit_Framework_Exception
4041 public function testAssertNotInternalTypeThrowsExceptionForInvalidArgument()
4043 $this->assertNotInternalType(null, 1);
4047 * @covers PHPUnit_Framework_Assert::assertAttributeNotInternalType
4049 public function testAssertAttributeNotInternalType()
4054 $this->assertAttributeNotInternalType('string', 'a', $o);
4058 * @covers PHPUnit_Framework_Assert::assertStringMatchesFormatFile
4059 * @expectedException PHPUnit_Framework_Exception
4061 public function testAssertStringMatchesFormatFileThrowsExceptionForInvalidArgument()
4063 $this->assertStringMatchesFormatFile('not_existing_file', '');
4067 * @covers PHPUnit_Framework_Assert::assertStringMatchesFormatFile
4068 * @expectedException PHPUnit_Framework_Exception
4070 public function testAssertStringMatchesFormatFileThrowsExceptionForInvalidArgument2()
4072 $this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', null);
4076 * @covers PHPUnit_Framework_Assert::assertStringMatchesFormatFile
4078 public function testAssertStringMatchesFormatFile()
4080 $this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "FOO\n");
4083 $this->assertStringMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "BAR\n");
4084 } catch (PHPUnit_Framework_AssertionFailedError $e) {
4092 * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile
4093 * @expectedException PHPUnit_Framework_Exception
4095 public function testAssertStringNotMatchesFormatFileThrowsExceptionForInvalidArgument()
4097 $this->assertStringNotMatchesFormatFile('not_existing_file', '');
4101 * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile
4102 * @expectedException PHPUnit_Framework_Exception
4104 public function testAssertStringNotMatchesFormatFileThrowsExceptionForInvalidArgument2()
4106 $this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', null);
4110 * @covers PHPUnit_Framework_Assert::assertStringNotMatchesFormatFile
4112 public function testAssertStringNotMatchesFormatFile()
4114 $this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "BAR\n");
4117 $this->assertStringNotMatchesFormatFile($this->filesDirectory . 'expectedFileFormat.txt', "FOO\n");
4118 } catch (PHPUnit_Framework_AssertionFailedError $e) {
4128 public static function validInvalidJsonDataprovider()
4131 'error syntax in expected JSON' => array('{"Mascott"::}', '{"Mascott" : "Tux"}'),
4132 'error UTF-8 in actual JSON' => array('{"Mascott" : "Tux"}', '{"Mascott" : :}'),