Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like PHPUnit_Framework_Assert often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PHPUnit_Framework_Assert, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | abstract class PHPUnit_Framework_Assert |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * @var int |
||
20 | */ |
||
21 | private static $count = 0; |
||
22 | |||
23 | /** |
||
24 | * Asserts that an array has a specified key. |
||
25 | * |
||
26 | * @param mixed $key |
||
27 | * @param array|ArrayAccess $array |
||
28 | * @param string $message |
||
29 | * |
||
30 | * @since Method available since Release 3.0.0 |
||
31 | */ |
||
32 | public static function assertArrayHasKey($key, $array, $message = '') |
||
52 | |||
53 | /** |
||
54 | * Asserts that an array has a specified subset. |
||
55 | * |
||
56 | * @param array|ArrayAccess $subset |
||
57 | * @param array|ArrayAccess $array |
||
58 | * @param bool $strict Check for object identity |
||
59 | * @param string $message |
||
60 | * |
||
61 | * @since Method available since Release 4.4.0 |
||
62 | */ |
||
63 | View Code Duplication | public static function assertArraySubset($subset, $array, $strict = false, $message = '') |
|
83 | |||
84 | /** |
||
85 | * Asserts that an array does not have a specified key. |
||
86 | * |
||
87 | * @param mixed $key |
||
88 | * @param array|ArrayAccess $array |
||
89 | * @param string $message |
||
90 | * |
||
91 | * @since Method available since Release 3.0.0 |
||
92 | */ |
||
93 | public static function assertArrayNotHasKey($key, $array, $message = '') |
||
115 | |||
116 | /** |
||
117 | * Asserts that a haystack contains a needle. |
||
118 | * |
||
119 | * @param mixed $needle |
||
120 | * @param mixed $haystack |
||
121 | * @param string $message |
||
122 | * @param bool $ignoreCase |
||
123 | * @param bool $checkForObjectIdentity |
||
124 | * @param bool $checkForNonObjectIdentity |
||
125 | * |
||
126 | * @since Method available since Release 2.1.0 |
||
127 | */ |
||
128 | View Code Duplication | public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
|
158 | |||
159 | /** |
||
160 | * Asserts that a haystack that is stored in a static attribute of a class |
||
161 | * or an attribute of an object contains a needle. |
||
162 | * |
||
163 | * @param mixed $needle |
||
164 | * @param string $haystackAttributeName |
||
165 | * @param mixed $haystackClassOrObject |
||
166 | * @param string $message |
||
167 | * @param bool $ignoreCase |
||
168 | * @param bool $checkForObjectIdentity |
||
169 | * @param bool $checkForNonObjectIdentity |
||
170 | * |
||
171 | * @since Method available since Release 3.0.0 |
||
172 | */ |
||
173 | View Code Duplication | public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
|
184 | |||
185 | /** |
||
186 | * Asserts that a haystack does not contain a needle. |
||
187 | * |
||
188 | * @param mixed $needle |
||
189 | * @param mixed $haystack |
||
190 | * @param string $message |
||
191 | * @param bool $ignoreCase |
||
192 | * @param bool $checkForObjectIdentity |
||
193 | * @param bool $checkForNonObjectIdentity |
||
194 | * |
||
195 | * @since Method available since Release 2.1.0 |
||
196 | */ |
||
197 | View Code Duplication | public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
|
231 | |||
232 | /** |
||
233 | * Asserts that a haystack that is stored in a static attribute of a class |
||
234 | * or an attribute of an object does not contain a needle. |
||
235 | * |
||
236 | * @param mixed $needle |
||
237 | * @param string $haystackAttributeName |
||
238 | * @param mixed $haystackClassOrObject |
||
239 | * @param string $message |
||
240 | * @param bool $ignoreCase |
||
241 | * @param bool $checkForObjectIdentity |
||
242 | * @param bool $checkForNonObjectIdentity |
||
243 | * |
||
244 | * @since Method available since Release 3.0.0 |
||
245 | */ |
||
246 | View Code Duplication | public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
|
257 | |||
258 | /** |
||
259 | * Asserts that a haystack contains only values of a given type. |
||
260 | * |
||
261 | * @param string $type |
||
262 | * @param mixed $haystack |
||
263 | * @param bool $isNativeType |
||
264 | * @param string $message |
||
265 | * |
||
266 | * @since Method available since Release 3.1.4 |
||
267 | */ |
||
268 | View Code Duplication | public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
|
291 | |||
292 | /** |
||
293 | * Asserts that a haystack contains only instances of a given classname |
||
294 | * |
||
295 | * @param string $classname |
||
296 | * @param array|Traversable $haystack |
||
297 | * @param string $message |
||
298 | */ |
||
299 | public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '') |
||
318 | |||
319 | /** |
||
320 | * Asserts that a haystack that is stored in a static attribute of a class |
||
321 | * or an attribute of an object contains only values of a given type. |
||
322 | * |
||
323 | * @param string $type |
||
324 | * @param string $haystackAttributeName |
||
325 | * @param mixed $haystackClassOrObject |
||
326 | * @param bool $isNativeType |
||
327 | * @param string $message |
||
328 | * |
||
329 | * @since Method available since Release 3.1.4 |
||
330 | */ |
||
331 | public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '') |
||
340 | |||
341 | /** |
||
342 | * Asserts that a haystack does not contain only values of a given type. |
||
343 | * |
||
344 | * @param string $type |
||
345 | * @param mixed $haystack |
||
346 | * @param bool $isNativeType |
||
347 | * @param string $message |
||
348 | * |
||
349 | * @since Method available since Release 3.1.4 |
||
350 | */ |
||
351 | View Code Duplication | public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
|
376 | |||
377 | /** |
||
378 | * Asserts that a haystack that is stored in a static attribute of a class |
||
379 | * or an attribute of an object does not contain only values of a given |
||
380 | * type. |
||
381 | * |
||
382 | * @param string $type |
||
383 | * @param string $haystackAttributeName |
||
384 | * @param mixed $haystackClassOrObject |
||
385 | * @param bool $isNativeType |
||
386 | * @param string $message |
||
387 | * |
||
388 | * @since Method available since Release 3.1.4 |
||
389 | */ |
||
390 | public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '') |
||
399 | |||
400 | /** |
||
401 | * Asserts the number of elements of an array, Countable or Traversable. |
||
402 | * |
||
403 | * @param int $expectedCount |
||
404 | * @param mixed $haystack |
||
405 | * @param string $message |
||
406 | */ |
||
407 | View Code Duplication | public static function assertCount($expectedCount, $haystack, $message = '') |
|
425 | |||
426 | /** |
||
427 | * Asserts the number of elements of an array, Countable or Traversable |
||
428 | * that is stored in an attribute. |
||
429 | * |
||
430 | * @param int $expectedCount |
||
431 | * @param string $haystackAttributeName |
||
432 | * @param mixed $haystackClassOrObject |
||
433 | * @param string $message |
||
434 | * |
||
435 | * @since Method available since Release 3.6.0 |
||
436 | */ |
||
437 | public static function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') |
||
445 | |||
446 | /** |
||
447 | * Asserts the number of elements of an array, Countable or Traversable. |
||
448 | * |
||
449 | * @param int $expectedCount |
||
450 | * @param mixed $haystack |
||
451 | * @param string $message |
||
452 | */ |
||
453 | View Code Duplication | public static function assertNotCount($expectedCount, $haystack, $message = '') |
|
471 | |||
472 | /** |
||
473 | * Asserts the number of elements of an array, Countable or Traversable |
||
474 | * that is stored in an attribute. |
||
475 | * |
||
476 | * @param int $expectedCount |
||
477 | * @param string $haystackAttributeName |
||
478 | * @param mixed $haystackClassOrObject |
||
479 | * @param string $message |
||
480 | * |
||
481 | * @since Method available since Release 3.6.0 |
||
482 | */ |
||
483 | public static function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') |
||
491 | |||
492 | /** |
||
493 | * Asserts that two variables are equal. |
||
494 | * |
||
495 | * @param mixed $expected |
||
496 | * @param mixed $actual |
||
497 | * @param string $message |
||
498 | * @param float $delta |
||
499 | * @param int $maxDepth |
||
500 | * @param bool $canonicalize |
||
501 | * @param bool $ignoreCase |
||
502 | */ |
||
503 | View Code Duplication | public static function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
|
515 | |||
516 | /** |
||
517 | * Asserts that a variable is equal to an attribute of an object. |
||
518 | * |
||
519 | * @param mixed $expected |
||
520 | * @param string $actualAttributeName |
||
521 | * @param string $actualClassOrObject |
||
522 | * @param string $message |
||
523 | * @param float $delta |
||
524 | * @param int $maxDepth |
||
525 | * @param bool $canonicalize |
||
526 | * @param bool $ignoreCase |
||
527 | */ |
||
528 | View Code Duplication | public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
|
540 | |||
541 | /** |
||
542 | * Asserts that two variables are not equal. |
||
543 | * |
||
544 | * @param mixed $expected |
||
545 | * @param mixed $actual |
||
546 | * @param string $message |
||
547 | * @param float $delta |
||
548 | * @param int $maxDepth |
||
549 | * @param bool $canonicalize |
||
550 | * @param bool $ignoreCase |
||
551 | * |
||
552 | * @since Method available since Release 2.3.0 |
||
553 | */ |
||
554 | View Code Duplication | public static function assertNotEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
|
568 | |||
569 | /** |
||
570 | * Asserts that a variable is not equal to an attribute of an object. |
||
571 | * |
||
572 | * @param mixed $expected |
||
573 | * @param string $actualAttributeName |
||
574 | * @param string $actualClassOrObject |
||
575 | * @param string $message |
||
576 | * @param float $delta |
||
577 | * @param int $maxDepth |
||
578 | * @param bool $canonicalize |
||
579 | * @param bool $ignoreCase |
||
580 | */ |
||
581 | View Code Duplication | public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
|
593 | |||
594 | /** |
||
595 | * Asserts that a variable is empty. |
||
596 | * |
||
597 | * @param mixed $actual |
||
598 | * @param string $message |
||
599 | * |
||
600 | * @throws PHPUnit_Framework_AssertionFailedError |
||
601 | */ |
||
602 | public static function assertEmpty($actual, $message = '') |
||
606 | |||
607 | /** |
||
608 | * Asserts that a static attribute of a class or an attribute of an object |
||
609 | * is empty. |
||
610 | * |
||
611 | * @param string $haystackAttributeName |
||
612 | * @param mixed $haystackClassOrObject |
||
613 | * @param string $message |
||
614 | * |
||
615 | * @since Method available since Release 3.5.0 |
||
616 | */ |
||
617 | public static function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') |
||
624 | |||
625 | /** |
||
626 | * Asserts that a variable is not empty. |
||
627 | * |
||
628 | * @param mixed $actual |
||
629 | * @param string $message |
||
630 | * |
||
631 | * @throws PHPUnit_Framework_AssertionFailedError |
||
632 | */ |
||
633 | public static function assertNotEmpty($actual, $message = '') |
||
637 | |||
638 | /** |
||
639 | * Asserts that a static attribute of a class or an attribute of an object |
||
640 | * is not empty. |
||
641 | * |
||
642 | * @param string $haystackAttributeName |
||
643 | * @param mixed $haystackClassOrObject |
||
644 | * @param string $message |
||
645 | * |
||
646 | * @since Method available since Release 3.5.0 |
||
647 | */ |
||
648 | public static function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') |
||
655 | |||
656 | /** |
||
657 | * Asserts that a value is greater than another value. |
||
658 | * |
||
659 | * @param mixed $expected |
||
660 | * @param mixed $actual |
||
661 | * @param string $message |
||
662 | * |
||
663 | * @since Method available since Release 3.1.0 |
||
664 | */ |
||
665 | public static function assertGreaterThan($expected, $actual, $message = '') |
||
669 | |||
670 | /** |
||
671 | * Asserts that an attribute is greater than another value. |
||
672 | * |
||
673 | * @param mixed $expected |
||
674 | * @param string $actualAttributeName |
||
675 | * @param string $actualClassOrObject |
||
676 | * @param string $message |
||
677 | * |
||
678 | * @since Method available since Release 3.1.0 |
||
679 | */ |
||
680 | public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
688 | |||
689 | /** |
||
690 | * Asserts that a value is greater than or equal to another value. |
||
691 | * |
||
692 | * @param mixed $expected |
||
693 | * @param mixed $actual |
||
694 | * @param string $message |
||
695 | * |
||
696 | * @since Method available since Release 3.1.0 |
||
697 | */ |
||
698 | public static function assertGreaterThanOrEqual($expected, $actual, $message = '') |
||
706 | |||
707 | /** |
||
708 | * Asserts that an attribute is greater than or equal to another value. |
||
709 | * |
||
710 | * @param mixed $expected |
||
711 | * @param string $actualAttributeName |
||
712 | * @param string $actualClassOrObject |
||
713 | * @param string $message |
||
714 | * |
||
715 | * @since Method available since Release 3.1.0 |
||
716 | */ |
||
717 | public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
725 | |||
726 | /** |
||
727 | * Asserts that a value is smaller than another value. |
||
728 | * |
||
729 | * @param mixed $expected |
||
730 | * @param mixed $actual |
||
731 | * @param string $message |
||
732 | * |
||
733 | * @since Method available since Release 3.1.0 |
||
734 | */ |
||
735 | public static function assertLessThan($expected, $actual, $message = '') |
||
739 | |||
740 | /** |
||
741 | * Asserts that an attribute is smaller than another value. |
||
742 | * |
||
743 | * @param mixed $expected |
||
744 | * @param string $actualAttributeName |
||
745 | * @param string $actualClassOrObject |
||
746 | * @param string $message |
||
747 | * |
||
748 | * @since Method available since Release 3.1.0 |
||
749 | */ |
||
750 | public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
758 | |||
759 | /** |
||
760 | * Asserts that a value is smaller than or equal to another value. |
||
761 | * |
||
762 | * @param mixed $expected |
||
763 | * @param mixed $actual |
||
764 | * @param string $message |
||
765 | * |
||
766 | * @since Method available since Release 3.1.0 |
||
767 | */ |
||
768 | public static function assertLessThanOrEqual($expected, $actual, $message = '') |
||
772 | |||
773 | /** |
||
774 | * Asserts that an attribute is smaller than or equal to another value. |
||
775 | * |
||
776 | * @param mixed $expected |
||
777 | * @param string $actualAttributeName |
||
778 | * @param string $actualClassOrObject |
||
779 | * @param string $message |
||
780 | * |
||
781 | * @since Method available since Release 3.1.0 |
||
782 | */ |
||
783 | public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
791 | |||
792 | /** |
||
793 | * Asserts that the contents of one file is equal to the contents of another |
||
794 | * file. |
||
795 | * |
||
796 | * @param string $expected |
||
797 | * @param string $actual |
||
798 | * @param string $message |
||
799 | * @param bool $canonicalize |
||
800 | * @param bool $ignoreCase |
||
801 | * |
||
802 | * @since Method available since Release 3.2.14 |
||
803 | */ |
||
804 | View Code Duplication | public static function assertFileEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false) |
|
819 | |||
820 | /** |
||
821 | * Asserts that the contents of one file is not equal to the contents of |
||
822 | * another file. |
||
823 | * |
||
824 | * @param string $expected |
||
825 | * @param string $actual |
||
826 | * @param string $message |
||
827 | * @param bool $canonicalize |
||
828 | * @param bool $ignoreCase |
||
829 | * |
||
830 | * @since Method available since Release 3.2.14 |
||
831 | */ |
||
832 | View Code Duplication | public static function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false) |
|
847 | |||
848 | /** |
||
849 | * Asserts that the contents of a string is equal |
||
850 | * to the contents of a file. |
||
851 | * |
||
852 | * @param string $expectedFile |
||
853 | * @param string $actualString |
||
854 | * @param string $message |
||
855 | * @param bool $canonicalize |
||
856 | * @param bool $ignoreCase |
||
857 | * |
||
858 | * @since Method available since Release 3.3.0 |
||
859 | */ |
||
860 | View Code Duplication | public static function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false) |
|
874 | |||
875 | /** |
||
876 | * Asserts that the contents of a string is not equal |
||
877 | * to the contents of a file. |
||
878 | * |
||
879 | * @param string $expectedFile |
||
880 | * @param string $actualString |
||
881 | * @param string $message |
||
882 | * @param bool $canonicalize |
||
883 | * @param bool $ignoreCase |
||
884 | * |
||
885 | * @since Method available since Release 3.3.0 |
||
886 | */ |
||
887 | View Code Duplication | public static function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false) |
|
901 | |||
902 | /** |
||
903 | * Asserts that a file exists. |
||
904 | * |
||
905 | * @param string $filename |
||
906 | * @param string $message |
||
907 | * |
||
908 | * @since Method available since Release 3.0.0 |
||
909 | */ |
||
910 | public static function assertFileExists($filename, $message = '') |
||
920 | |||
921 | /** |
||
922 | * Asserts that a file does not exist. |
||
923 | * |
||
924 | * @param string $filename |
||
925 | * @param string $message |
||
926 | * |
||
927 | * @since Method available since Release 3.0.0 |
||
928 | */ |
||
929 | public static function assertFileNotExists($filename, $message = '') |
||
941 | |||
942 | /** |
||
943 | * Asserts that a condition is true. |
||
944 | * |
||
945 | * @param bool $condition |
||
946 | * @param string $message |
||
947 | * |
||
948 | * @throws PHPUnit_Framework_AssertionFailedError |
||
949 | */ |
||
950 | public static function assertTrue($condition, $message = '') |
||
954 | |||
955 | /** |
||
956 | * Asserts that a condition is not true. |
||
957 | * |
||
958 | * @param bool $condition |
||
959 | * @param string $message |
||
960 | * |
||
961 | * @throws PHPUnit_Framework_AssertionFailedError |
||
962 | */ |
||
963 | public static function assertNotTrue($condition, $message = '') |
||
967 | |||
968 | /** |
||
969 | * Asserts that a condition is false. |
||
970 | * |
||
971 | * @param bool $condition |
||
972 | * @param string $message |
||
973 | * |
||
974 | * @throws PHPUnit_Framework_AssertionFailedError |
||
975 | */ |
||
976 | public static function assertFalse($condition, $message = '') |
||
980 | |||
981 | /** |
||
982 | * Asserts that a condition is not false. |
||
983 | * |
||
984 | * @param bool $condition |
||
985 | * @param string $message |
||
986 | * |
||
987 | * @throws PHPUnit_Framework_AssertionFailedError |
||
988 | */ |
||
989 | public static function assertNotFalse($condition, $message = '') |
||
993 | |||
994 | /** |
||
995 | * Asserts that a variable is not null. |
||
996 | * |
||
997 | * @param mixed $actual |
||
998 | * @param string $message |
||
999 | */ |
||
1000 | public static function assertNotNull($actual, $message = '') |
||
1004 | |||
1005 | /** |
||
1006 | * Asserts that a variable is null. |
||
1007 | * |
||
1008 | * @param mixed $actual |
||
1009 | * @param string $message |
||
1010 | */ |
||
1011 | public static function assertNull($actual, $message = '') |
||
1015 | |||
1016 | /** |
||
1017 | * Asserts that a class has a specified attribute. |
||
1018 | * |
||
1019 | * @param string $attributeName |
||
1020 | * @param string $className |
||
1021 | * @param string $message |
||
1022 | * |
||
1023 | * @since Method available since Release 3.1.0 |
||
1024 | */ |
||
1025 | View Code Duplication | public static function assertClassHasAttribute($attributeName, $className, $message = '') |
|
1045 | |||
1046 | /** |
||
1047 | * Asserts that a class does not have a specified attribute. |
||
1048 | * |
||
1049 | * @param string $attributeName |
||
1050 | * @param string $className |
||
1051 | * @param string $message |
||
1052 | * |
||
1053 | * @since Method available since Release 3.1.0 |
||
1054 | */ |
||
1055 | View Code Duplication | public static function assertClassNotHasAttribute($attributeName, $className, $message = '') |
|
1075 | |||
1076 | /** |
||
1077 | * Asserts that a class has a specified static attribute. |
||
1078 | * |
||
1079 | * @param string $attributeName |
||
1080 | * @param string $className |
||
1081 | * @param string $message |
||
1082 | * |
||
1083 | * @since Method available since Release 3.1.0 |
||
1084 | */ |
||
1085 | View Code Duplication | public static function assertClassHasStaticAttribute($attributeName, $className, $message = '') |
|
1105 | |||
1106 | /** |
||
1107 | * Asserts that a class does not have a specified static attribute. |
||
1108 | * |
||
1109 | * @param string $attributeName |
||
1110 | * @param string $className |
||
1111 | * @param string $message |
||
1112 | * |
||
1113 | * @since Method available since Release 3.1.0 |
||
1114 | */ |
||
1115 | View Code Duplication | public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') |
|
1137 | |||
1138 | /** |
||
1139 | * Asserts that an object has a specified attribute. |
||
1140 | * |
||
1141 | * @param string $attributeName |
||
1142 | * @param object $object |
||
1143 | * @param string $message |
||
1144 | * |
||
1145 | * @since Method available since Release 3.0.0 |
||
1146 | */ |
||
1147 | View Code Duplication | public static function assertObjectHasAttribute($attributeName, $object, $message = '') |
|
1167 | |||
1168 | /** |
||
1169 | * Asserts that an object does not have a specified attribute. |
||
1170 | * |
||
1171 | * @param string $attributeName |
||
1172 | * @param object $object |
||
1173 | * @param string $message |
||
1174 | * |
||
1175 | * @since Method available since Release 3.0.0 |
||
1176 | */ |
||
1177 | View Code Duplication | public static function assertObjectNotHasAttribute($attributeName, $object, $message = '') |
|
1197 | |||
1198 | /** |
||
1199 | * Asserts that two variables have the same type and value. |
||
1200 | * Used on objects, it asserts that two variables reference |
||
1201 | * the same object. |
||
1202 | * |
||
1203 | * @param mixed $expected |
||
1204 | * @param mixed $actual |
||
1205 | * @param string $message |
||
1206 | */ |
||
1207 | public static function assertSame($expected, $actual, $message = '') |
||
1219 | |||
1220 | /** |
||
1221 | * Asserts that a variable and an attribute of an object have the same type |
||
1222 | * and value. |
||
1223 | * |
||
1224 | * @param mixed $expected |
||
1225 | * @param string $actualAttributeName |
||
1226 | * @param object $actualClassOrObject |
||
1227 | * @param string $message |
||
1228 | */ |
||
1229 | public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
1237 | |||
1238 | /** |
||
1239 | * Asserts that two variables do not have the same type and value. |
||
1240 | * Used on objects, it asserts that two variables do not reference |
||
1241 | * the same object. |
||
1242 | * |
||
1243 | * @param mixed $expected |
||
1244 | * @param mixed $actual |
||
1245 | * @param string $message |
||
1246 | */ |
||
1247 | public static function assertNotSame($expected, $actual, $message = '') |
||
1259 | |||
1260 | /** |
||
1261 | * Asserts that a variable and an attribute of an object do not have the |
||
1262 | * same type and value. |
||
1263 | * |
||
1264 | * @param mixed $expected |
||
1265 | * @param string $actualAttributeName |
||
1266 | * @param object $actualClassOrObject |
||
1267 | * @param string $message |
||
1268 | */ |
||
1269 | public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
1277 | |||
1278 | /** |
||
1279 | * Asserts that a variable is of a given type. |
||
1280 | * |
||
1281 | * @param string $expected |
||
1282 | * @param mixed $actual |
||
1283 | * @param string $message |
||
1284 | * |
||
1285 | * @since Method available since Release 3.5.0 |
||
1286 | */ |
||
1287 | public static function assertInstanceOf($expected, $actual, $message = '') |
||
1299 | |||
1300 | /** |
||
1301 | * Asserts that an attribute is of a given type. |
||
1302 | * |
||
1303 | * @param string $expected |
||
1304 | * @param string $attributeName |
||
1305 | * @param mixed $classOrObject |
||
1306 | * @param string $message |
||
1307 | * |
||
1308 | * @since Method available since Release 3.5.0 |
||
1309 | */ |
||
1310 | public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') |
||
1318 | |||
1319 | /** |
||
1320 | * Asserts that a variable is not of a given type. |
||
1321 | * |
||
1322 | * @param string $expected |
||
1323 | * @param mixed $actual |
||
1324 | * @param string $message |
||
1325 | * |
||
1326 | * @since Method available since Release 3.5.0 |
||
1327 | */ |
||
1328 | public static function assertNotInstanceOf($expected, $actual, $message = '') |
||
1340 | |||
1341 | /** |
||
1342 | * Asserts that an attribute is of a given type. |
||
1343 | * |
||
1344 | * @param string $expected |
||
1345 | * @param string $attributeName |
||
1346 | * @param mixed $classOrObject |
||
1347 | * @param string $message |
||
1348 | * |
||
1349 | * @since Method available since Release 3.5.0 |
||
1350 | */ |
||
1351 | public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') |
||
1359 | |||
1360 | /** |
||
1361 | * Asserts that a variable is of a given type. |
||
1362 | * |
||
1363 | * @param string $expected |
||
1364 | * @param mixed $actual |
||
1365 | * @param string $message |
||
1366 | * |
||
1367 | * @since Method available since Release 3.5.0 |
||
1368 | */ |
||
1369 | public static function assertInternalType($expected, $actual, $message = '') |
||
1381 | |||
1382 | /** |
||
1383 | * Asserts that an attribute is of a given type. |
||
1384 | * |
||
1385 | * @param string $expected |
||
1386 | * @param string $attributeName |
||
1387 | * @param mixed $classOrObject |
||
1388 | * @param string $message |
||
1389 | * |
||
1390 | * @since Method available since Release 3.5.0 |
||
1391 | */ |
||
1392 | public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') |
||
1400 | |||
1401 | /** |
||
1402 | * Asserts that a variable is not of a given type. |
||
1403 | * |
||
1404 | * @param string $expected |
||
1405 | * @param mixed $actual |
||
1406 | * @param string $message |
||
1407 | * |
||
1408 | * @since Method available since Release 3.5.0 |
||
1409 | */ |
||
1410 | public static function assertNotInternalType($expected, $actual, $message = '') |
||
1422 | |||
1423 | /** |
||
1424 | * Asserts that an attribute is of a given type. |
||
1425 | * |
||
1426 | * @param string $expected |
||
1427 | * @param string $attributeName |
||
1428 | * @param mixed $classOrObject |
||
1429 | * @param string $message |
||
1430 | * |
||
1431 | * @since Method available since Release 3.5.0 |
||
1432 | */ |
||
1433 | public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') |
||
1441 | |||
1442 | /** |
||
1443 | * Asserts that a string matches a given regular expression. |
||
1444 | * |
||
1445 | * @param string $pattern |
||
1446 | * @param string $string |
||
1447 | * @param string $message |
||
1448 | */ |
||
1449 | View Code Duplication | public static function assertRegExp($pattern, $string, $message = '') |
|
1463 | |||
1464 | /** |
||
1465 | * Asserts that a string does not match a given regular expression. |
||
1466 | * |
||
1467 | * @param string $pattern |
||
1468 | * @param string $string |
||
1469 | * @param string $message |
||
1470 | * |
||
1471 | * @since Method available since Release 2.1.0 |
||
1472 | */ |
||
1473 | View Code Duplication | public static function assertNotRegExp($pattern, $string, $message = '') |
|
1489 | |||
1490 | /** |
||
1491 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) |
||
1492 | * is the same. |
||
1493 | * |
||
1494 | * @param array|Countable|Traversable $expected |
||
1495 | * @param array|Countable|Traversable $actual |
||
1496 | * @param string $message |
||
1497 | */ |
||
1498 | View Code Duplication | public static function assertSameSize($expected, $actual, $message = '') |
|
1518 | |||
1519 | /** |
||
1520 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) |
||
1521 | * is not the same. |
||
1522 | * |
||
1523 | * @param array|Countable|Traversable $expected |
||
1524 | * @param array|Countable|Traversable $actual |
||
1525 | * @param string $message |
||
1526 | */ |
||
1527 | View Code Duplication | public static function assertNotSameSize($expected, $actual, $message = '') |
|
1547 | |||
1548 | /** |
||
1549 | * Asserts that a string matches a given format string. |
||
1550 | * |
||
1551 | * @param string $format |
||
1552 | * @param string $string |
||
1553 | * @param string $message |
||
1554 | * |
||
1555 | * @since Method available since Release 3.5.0 |
||
1556 | */ |
||
1557 | View Code Duplication | public static function assertStringMatchesFormat($format, $string, $message = '') |
|
1571 | |||
1572 | /** |
||
1573 | * Asserts that a string does not match a given format string. |
||
1574 | * |
||
1575 | * @param string $format |
||
1576 | * @param string $string |
||
1577 | * @param string $message |
||
1578 | * |
||
1579 | * @since Method available since Release 3.5.0 |
||
1580 | */ |
||
1581 | View Code Duplication | public static function assertStringNotMatchesFormat($format, $string, $message = '') |
|
1597 | |||
1598 | /** |
||
1599 | * Asserts that a string matches a given format file. |
||
1600 | * |
||
1601 | * @param string $formatFile |
||
1602 | * @param string $string |
||
1603 | * @param string $message |
||
1604 | * |
||
1605 | * @since Method available since Release 3.5.0 |
||
1606 | */ |
||
1607 | public static function assertStringMatchesFormatFile($formatFile, $string, $message = '') |
||
1621 | |||
1622 | /** |
||
1623 | * Asserts that a string does not match a given format string. |
||
1624 | * |
||
1625 | * @param string $formatFile |
||
1626 | * @param string $string |
||
1627 | * @param string $message |
||
1628 | * |
||
1629 | * @since Method available since Release 3.5.0 |
||
1630 | */ |
||
1631 | public static function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') |
||
1647 | |||
1648 | /** |
||
1649 | * Asserts that a string starts with a given prefix. |
||
1650 | * |
||
1651 | * @param string $prefix |
||
1652 | * @param string $string |
||
1653 | * @param string $message |
||
1654 | * |
||
1655 | * @since Method available since Release 3.4.0 |
||
1656 | */ |
||
1657 | View Code Duplication | public static function assertStringStartsWith($prefix, $string, $message = '') |
|
1673 | |||
1674 | /** |
||
1675 | * Asserts that a string starts not with a given prefix. |
||
1676 | * |
||
1677 | * @param string $prefix |
||
1678 | * @param string $string |
||
1679 | * @param string $message |
||
1680 | * |
||
1681 | * @since Method available since Release 3.4.0 |
||
1682 | */ |
||
1683 | View Code Duplication | public static function assertStringStartsNotWith($prefix, $string, $message = '') |
|
1699 | |||
1700 | /** |
||
1701 | * Asserts that a string ends with a given suffix. |
||
1702 | * |
||
1703 | * @param string $suffix |
||
1704 | * @param string $string |
||
1705 | * @param string $message |
||
1706 | * |
||
1707 | * @since Method available since Release 3.4.0 |
||
1708 | */ |
||
1709 | View Code Duplication | public static function assertStringEndsWith($suffix, $string, $message = '') |
|
1723 | |||
1724 | /** |
||
1725 | * Asserts that a string ends not with a given suffix. |
||
1726 | * |
||
1727 | * @param string $suffix |
||
1728 | * @param string $string |
||
1729 | * @param string $message |
||
1730 | * |
||
1731 | * @since Method available since Release 3.4.0 |
||
1732 | */ |
||
1733 | View Code Duplication | public static function assertStringEndsNotWith($suffix, $string, $message = '') |
|
1749 | |||
1750 | /** |
||
1751 | * Asserts that two XML files are equal. |
||
1752 | * |
||
1753 | * @param string $expectedFile |
||
1754 | * @param string $actualFile |
||
1755 | * @param string $message |
||
1756 | * |
||
1757 | * @since Method available since Release 3.1.0 |
||
1758 | */ |
||
1759 | public static function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') |
||
1766 | |||
1767 | /** |
||
1768 | * Asserts that two XML files are not equal. |
||
1769 | * |
||
1770 | * @param string $expectedFile |
||
1771 | * @param string $actualFile |
||
1772 | * @param string $message |
||
1773 | * |
||
1774 | * @since Method available since Release 3.1.0 |
||
1775 | */ |
||
1776 | public static function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') |
||
1783 | |||
1784 | /** |
||
1785 | * Asserts that two XML documents are equal. |
||
1786 | * |
||
1787 | * @param string $expectedFile |
||
1788 | * @param string $actualXml |
||
1789 | * @param string $message |
||
1790 | * |
||
1791 | * @since Method available since Release 3.3.0 |
||
1792 | */ |
||
1793 | View Code Duplication | public static function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') |
|
1800 | |||
1801 | /** |
||
1802 | * Asserts that two XML documents are not equal. |
||
1803 | * |
||
1804 | * @param string $expectedFile |
||
1805 | * @param string $actualXml |
||
1806 | * @param string $message |
||
1807 | * |
||
1808 | * @since Method available since Release 3.3.0 |
||
1809 | */ |
||
1810 | public static function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') |
||
1817 | |||
1818 | /** |
||
1819 | * Asserts that two XML documents are equal. |
||
1820 | * |
||
1821 | * @param string $expectedXml |
||
1822 | * @param string $actualXml |
||
1823 | * @param string $message |
||
1824 | * |
||
1825 | * @since Method available since Release 3.1.0 |
||
1826 | */ |
||
1827 | View Code Duplication | public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') |
|
1834 | |||
1835 | /** |
||
1836 | * Asserts that two XML documents are not equal. |
||
1837 | * |
||
1838 | * @param string $expectedXml |
||
1839 | * @param string $actualXml |
||
1840 | * @param string $message |
||
1841 | * |
||
1842 | * @since Method available since Release 3.1.0 |
||
1843 | */ |
||
1844 | View Code Duplication | public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') |
|
1851 | |||
1852 | /** |
||
1853 | * Asserts that a hierarchy of DOMElements matches. |
||
1854 | * |
||
1855 | * @param DOMElement $expectedElement |
||
1856 | * @param DOMElement $actualElement |
||
1857 | * @param bool $checkAttributes |
||
1858 | * @param string $message |
||
1859 | * |
||
1860 | * @since Method available since Release 3.3.0 |
||
1861 | */ |
||
1862 | public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = false, $message = '') |
||
1933 | |||
1934 | /** |
||
1935 | * Assert the presence, absence, or count of elements in a document matching |
||
1936 | * the CSS $selector, regardless of the contents of those elements. |
||
1937 | * |
||
1938 | * The first argument, $selector, is the CSS selector used to match |
||
1939 | * the elements in the $actual document. |
||
1940 | * |
||
1941 | * The second argument, $count, can be either boolean or numeric. |
||
1942 | * When boolean, it asserts for presence of elements matching the selector |
||
1943 | * (true) or absence of elements (false). |
||
1944 | * When numeric, it asserts the count of elements. |
||
1945 | * |
||
1946 | * assertSelectCount("#binder", true, $xml); // any? |
||
1947 | * assertSelectCount(".binder", 3, $xml); // exactly 3? |
||
1948 | * |
||
1949 | * @param array $selector |
||
1950 | * @param int|bool|array $count |
||
1951 | * @param mixed $actual |
||
1952 | * @param string $message |
||
1953 | * @param bool $isHtml |
||
1954 | * |
||
1955 | * @since Method available since Release 3.3.0 |
||
1956 | * @deprecated |
||
1957 | * @codeCoverageIgnore |
||
1958 | */ |
||
1959 | View Code Duplication | public static function assertSelectCount($selector, $count, $actual, $message = '', $isHtml = true) |
|
1972 | |||
1973 | /** |
||
1974 | * assertSelectRegExp("#binder .name", "/Mike|Derek/", true, $xml); // any? |
||
1975 | * assertSelectRegExp("#binder .name", "/Mike|Derek/", 3, $xml); // 3? |
||
1976 | * |
||
1977 | * @param array $selector |
||
1978 | * @param string $pattern |
||
1979 | * @param int|bool|array $count |
||
1980 | * @param mixed $actual |
||
1981 | * @param string $message |
||
1982 | * @param bool $isHtml |
||
1983 | * |
||
1984 | * @since Method available since Release 3.3.0 |
||
1985 | * @deprecated |
||
1986 | * @codeCoverageIgnore |
||
1987 | */ |
||
1988 | View Code Duplication | public static function assertSelectRegExp($selector, $pattern, $count, $actual, $message = '', $isHtml = true) |
|
2001 | |||
2002 | /** |
||
2003 | * assertSelectEquals("#binder .name", "Chuck", true, $xml); // any? |
||
2004 | * assertSelectEquals("#binder .name", "Chuck", false, $xml); // none? |
||
2005 | * |
||
2006 | * @param array $selector |
||
2007 | * @param string $content |
||
2008 | * @param int|bool|array $count |
||
2009 | * @param mixed $actual |
||
2010 | * @param string $message |
||
2011 | * @param bool $isHtml |
||
2012 | * |
||
2013 | * @since Method available since Release 3.3.0 |
||
2014 | * @deprecated |
||
2015 | * @codeCoverageIgnore |
||
2016 | */ |
||
2017 | public static function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = true) |
||
2066 | |||
2067 | /** |
||
2068 | * Evaluate an HTML or XML string and assert its structure and/or contents. |
||
2069 | * |
||
2070 | * The first argument ($matcher) is an associative array that specifies the |
||
2071 | * match criteria for the assertion: |
||
2072 | * |
||
2073 | * - `id` : the node with the given id attribute must match the |
||
2074 | * corresponding value. |
||
2075 | * - `tag` : the node type must match the corresponding value. |
||
2076 | * - `attributes` : a hash. The node's attributes must match the |
||
2077 | * corresponding values in the hash. |
||
2078 | * - `content` : The text content must match the given value. |
||
2079 | * - `parent` : a hash. The node's parent must match the |
||
2080 | * corresponding hash. |
||
2081 | * - `child` : a hash. At least one of the node's immediate children |
||
2082 | * must meet the criteria described by the hash. |
||
2083 | * - `ancestor` : a hash. At least one of the node's ancestors must |
||
2084 | * meet the criteria described by the hash. |
||
2085 | * - `descendant` : a hash. At least one of the node's descendants must |
||
2086 | * meet the criteria described by the hash. |
||
2087 | * - `children` : a hash, for counting children of a node. |
||
2088 | * Accepts the keys: |
||
2089 | * - `count` : a number which must equal the number of children |
||
2090 | * that match |
||
2091 | * - `less_than` : the number of matching children must be greater |
||
2092 | * than this number |
||
2093 | * - `greater_than` : the number of matching children must be less than |
||
2094 | * this number |
||
2095 | * - `only` : another hash consisting of the keys to use to match |
||
2096 | * on the children, and only matching children will be |
||
2097 | * counted |
||
2098 | * |
||
2099 | * <code> |
||
2100 | * // Matcher that asserts that there is an element with an id="my_id". |
||
2101 | * $matcher = array('id' => 'my_id'); |
||
2102 | * |
||
2103 | * // Matcher that asserts that there is a "span" tag. |
||
2104 | * $matcher = array('tag' => 'span'); |
||
2105 | * |
||
2106 | * // Matcher that asserts that there is a "span" tag with the content |
||
2107 | * // "Hello World". |
||
2108 | * $matcher = array('tag' => 'span', 'content' => 'Hello World'); |
||
2109 | * |
||
2110 | * // Matcher that asserts that there is a "span" tag with content matching |
||
2111 | * // the regular expression pattern. |
||
2112 | * $matcher = array('tag' => 'span', 'content' => 'regexp:/Try P(HP|ython)/'); |
||
2113 | * |
||
2114 | * // Matcher that asserts that there is a "span" with an "list" class |
||
2115 | * // attribute. |
||
2116 | * $matcher = array( |
||
2117 | * 'tag' => 'span', |
||
2118 | * 'attributes' => array('class' => 'list') |
||
2119 | * ); |
||
2120 | * |
||
2121 | * // Matcher that asserts that there is a "span" inside of a "div". |
||
2122 | * $matcher = array( |
||
2123 | * 'tag' => 'span', |
||
2124 | * 'parent' => array('tag' => 'div') |
||
2125 | * ); |
||
2126 | * |
||
2127 | * // Matcher that asserts that there is a "span" somewhere inside a |
||
2128 | * // "table". |
||
2129 | * $matcher = array( |
||
2130 | * 'tag' => 'span', |
||
2131 | * 'ancestor' => array('tag' => 'table') |
||
2132 | * ); |
||
2133 | * |
||
2134 | * // Matcher that asserts that there is a "span" with at least one "em" |
||
2135 | * // child. |
||
2136 | * $matcher = array( |
||
2137 | * 'tag' => 'span', |
||
2138 | * 'child' => array('tag' => 'em') |
||
2139 | * ); |
||
2140 | * |
||
2141 | * // Matcher that asserts that there is a "span" containing a (possibly |
||
2142 | * // nested) "strong" tag. |
||
2143 | * $matcher = array( |
||
2144 | * 'tag' => 'span', |
||
2145 | * 'descendant' => array('tag' => 'strong') |
||
2146 | * ); |
||
2147 | * |
||
2148 | * // Matcher that asserts that there is a "span" containing 5-10 "em" tags |
||
2149 | * // as immediate children. |
||
2150 | * $matcher = array( |
||
2151 | * 'tag' => 'span', |
||
2152 | * 'children' => array( |
||
2153 | * 'less_than' => 11, |
||
2154 | * 'greater_than' => 4, |
||
2155 | * 'only' => array('tag' => 'em') |
||
2156 | * ) |
||
2157 | * ); |
||
2158 | * |
||
2159 | * // Matcher that asserts that there is a "div", with an "ul" ancestor and |
||
2160 | * // a "li" parent (with class="enum"), and containing a "span" descendant |
||
2161 | * // that contains an element with id="my_test" and the text "Hello World". |
||
2162 | * $matcher = array( |
||
2163 | * 'tag' => 'div', |
||
2164 | * 'ancestor' => array('tag' => 'ul'), |
||
2165 | * 'parent' => array( |
||
2166 | * 'tag' => 'li', |
||
2167 | * 'attributes' => array('class' => 'enum') |
||
2168 | * ), |
||
2169 | * 'descendant' => array( |
||
2170 | * 'tag' => 'span', |
||
2171 | * 'child' => array( |
||
2172 | * 'id' => 'my_test', |
||
2173 | * 'content' => 'Hello World' |
||
2174 | * ) |
||
2175 | * ) |
||
2176 | * ); |
||
2177 | * |
||
2178 | * // Use assertTag() to apply a $matcher to a piece of $html. |
||
2179 | * $this->assertTag($matcher, $html); |
||
2180 | * |
||
2181 | * // Use assertTag() to apply a $matcher to a piece of $xml. |
||
2182 | * $this->assertTag($matcher, $xml, '', false); |
||
2183 | * </code> |
||
2184 | * |
||
2185 | * The second argument ($actual) is a string containing either HTML or |
||
2186 | * XML text to be tested. |
||
2187 | * |
||
2188 | * The third argument ($message) is an optional message that will be |
||
2189 | * used if the assertion fails. |
||
2190 | * |
||
2191 | * The fourth argument ($html) is an optional flag specifying whether |
||
2192 | * to load the $actual string into a DOMDocument using the HTML or |
||
2193 | * XML load strategy. It is true by default, which assumes the HTML |
||
2194 | * load strategy. In many cases, this will be acceptable for XML as well. |
||
2195 | * |
||
2196 | * @param array $matcher |
||
2197 | * @param string $actual |
||
2198 | * @param string $message |
||
2199 | * @param bool $isHtml |
||
2200 | * |
||
2201 | * @since Method available since Release 3.3.0 |
||
2202 | * @deprecated |
||
2203 | * @codeCoverageIgnore |
||
2204 | */ |
||
2205 | View Code Duplication | public static function assertTag($matcher, $actual, $message = '', $isHtml = true) |
|
2215 | |||
2216 | /** |
||
2217 | * This assertion is the exact opposite of assertTag(). |
||
2218 | * |
||
2219 | * Rather than asserting that $matcher results in a match, it asserts that |
||
2220 | * $matcher does not match. |
||
2221 | * |
||
2222 | * @param array $matcher |
||
2223 | * @param string $actual |
||
2224 | * @param string $message |
||
2225 | * @param bool $isHtml |
||
2226 | * |
||
2227 | * @since Method available since Release 3.3.0 |
||
2228 | * @deprecated |
||
2229 | * @codeCoverageIgnore |
||
2230 | */ |
||
2231 | View Code Duplication | public static function assertNotTag($matcher, $actual, $message = '', $isHtml = true) |
|
2241 | |||
2242 | /** |
||
2243 | * Evaluates a PHPUnit_Framework_Constraint matcher object. |
||
2244 | * |
||
2245 | * @param mixed $value |
||
2246 | * @param PHPUnit_Framework_Constraint $constraint |
||
2247 | * @param string $message |
||
2248 | * |
||
2249 | * @since Method available since Release 3.0.0 |
||
2250 | */ |
||
2251 | public static function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '') |
||
2257 | |||
2258 | /** |
||
2259 | * Asserts that a string is a valid JSON string. |
||
2260 | * |
||
2261 | * @param string $actualJson |
||
2262 | * @param string $message |
||
2263 | * |
||
2264 | * @since Method available since Release 3.7.20 |
||
2265 | */ |
||
2266 | public static function assertJson($actualJson, $message = '') |
||
2274 | |||
2275 | /** |
||
2276 | * Asserts that two given JSON encoded objects or arrays are equal. |
||
2277 | * |
||
2278 | * @param string $expectedJson |
||
2279 | * @param string $actualJson |
||
2280 | * @param string $message |
||
2281 | */ |
||
2282 | View Code Duplication | public static function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') |
|
2292 | |||
2293 | /** |
||
2294 | * Asserts that two given JSON encoded objects or arrays are not equal. |
||
2295 | * |
||
2296 | * @param string $expectedJson |
||
2297 | * @param string $actualJson |
||
2298 | * @param string $message |
||
2299 | */ |
||
2300 | View Code Duplication | public static function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') |
|
2310 | |||
2311 | /** |
||
2312 | * Asserts that the generated JSON encoded object and the content of the given file are equal. |
||
2313 | * |
||
2314 | * @param string $expectedFile |
||
2315 | * @param string $actualJson |
||
2316 | * @param string $message |
||
2317 | */ |
||
2318 | View Code Duplication | public static function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '') |
|
2333 | |||
2334 | /** |
||
2335 | * Asserts that the generated JSON encoded object and the content of the given file are not equal. |
||
2336 | * |
||
2337 | * @param string $expectedFile |
||
2338 | * @param string $actualJson |
||
2339 | * @param string $message |
||
2340 | */ |
||
2341 | View Code Duplication | public static function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') |
|
2356 | |||
2357 | /** |
||
2358 | * Asserts that two JSON files are not equal. |
||
2359 | * |
||
2360 | * @param string $expectedFile |
||
2361 | * @param string $actualFile |
||
2362 | * @param string $message |
||
2363 | */ |
||
2364 | View Code Duplication | public static function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '') |
|
2385 | |||
2386 | /** |
||
2387 | * Asserts that two JSON files are equal. |
||
2388 | * |
||
2389 | * @param string $expectedFile |
||
2390 | * @param string $actualFile |
||
2391 | * @param string $message |
||
2392 | */ |
||
2393 | View Code Duplication | public static function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') |
|
2414 | |||
2415 | /** |
||
2416 | * Returns a PHPUnit_Framework_Constraint_And matcher object. |
||
2417 | * |
||
2418 | * @return PHPUnit_Framework_Constraint_And |
||
2419 | * |
||
2420 | * @since Method available since Release 3.0.0 |
||
2421 | */ |
||
2422 | public static function logicalAnd() |
||
2431 | |||
2432 | /** |
||
2433 | * Returns a PHPUnit_Framework_Constraint_Or matcher object. |
||
2434 | * |
||
2435 | * @return PHPUnit_Framework_Constraint_Or |
||
2436 | * |
||
2437 | * @since Method available since Release 3.0.0 |
||
2438 | */ |
||
2439 | public static function logicalOr() |
||
2448 | |||
2449 | /** |
||
2450 | * Returns a PHPUnit_Framework_Constraint_Not matcher object. |
||
2451 | * |
||
2452 | * @param PHPUnit_Framework_Constraint $constraint |
||
2453 | * |
||
2454 | * @return PHPUnit_Framework_Constraint_Not |
||
2455 | * |
||
2456 | * @since Method available since Release 3.0.0 |
||
2457 | */ |
||
2458 | public static function logicalNot(PHPUnit_Framework_Constraint $constraint) |
||
2462 | |||
2463 | /** |
||
2464 | * Returns a PHPUnit_Framework_Constraint_Xor matcher object. |
||
2465 | * |
||
2466 | * @return PHPUnit_Framework_Constraint_Xor |
||
2467 | * |
||
2468 | * @since Method available since Release 3.0.0 |
||
2469 | */ |
||
2470 | public static function logicalXor() |
||
2479 | |||
2480 | /** |
||
2481 | * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object. |
||
2482 | * |
||
2483 | * @return PHPUnit_Framework_Constraint_IsAnything |
||
2484 | * |
||
2485 | * @since Method available since Release 3.0.0 |
||
2486 | */ |
||
2487 | public static function anything() |
||
2491 | |||
2492 | /** |
||
2493 | * Returns a PHPUnit_Framework_Constraint_IsTrue matcher object. |
||
2494 | * |
||
2495 | * @return PHPUnit_Framework_Constraint_IsTrue |
||
2496 | * |
||
2497 | * @since Method available since Release 3.3.0 |
||
2498 | */ |
||
2499 | public static function isTrue() |
||
2503 | |||
2504 | /** |
||
2505 | * Returns a PHPUnit_Framework_Constraint_Callback matcher object. |
||
2506 | * |
||
2507 | * @param callable $callback |
||
2508 | * |
||
2509 | * @return PHPUnit_Framework_Constraint_Callback |
||
2510 | */ |
||
2511 | public static function callback($callback) |
||
2515 | |||
2516 | /** |
||
2517 | * Returns a PHPUnit_Framework_Constraint_IsFalse matcher object. |
||
2518 | * |
||
2519 | * @return PHPUnit_Framework_Constraint_IsFalse |
||
2520 | * |
||
2521 | * @since Method available since Release 3.3.0 |
||
2522 | */ |
||
2523 | public static function isFalse() |
||
2527 | |||
2528 | /** |
||
2529 | * Returns a PHPUnit_Framework_Constraint_IsJson matcher object. |
||
2530 | * |
||
2531 | * @return PHPUnit_Framework_Constraint_IsJson |
||
2532 | * |
||
2533 | * @since Method available since Release 3.7.20 |
||
2534 | */ |
||
2535 | public static function isJson() |
||
2539 | |||
2540 | /** |
||
2541 | * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. |
||
2542 | * |
||
2543 | * @return PHPUnit_Framework_Constraint_IsNull |
||
2544 | * |
||
2545 | * @since Method available since Release 3.3.0 |
||
2546 | */ |
||
2547 | public static function isNull() |
||
2551 | |||
2552 | /** |
||
2553 | * Returns a PHPUnit_Framework_Constraint_Attribute matcher object. |
||
2554 | * |
||
2555 | * @param PHPUnit_Framework_Constraint $constraint |
||
2556 | * @param string $attributeName |
||
2557 | * |
||
2558 | * @return PHPUnit_Framework_Constraint_Attribute |
||
2559 | * |
||
2560 | * @since Method available since Release 3.1.0 |
||
2561 | */ |
||
2562 | public static function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName) |
||
2569 | |||
2570 | /** |
||
2571 | * Returns a PHPUnit_Framework_Constraint_TraversableContains matcher |
||
2572 | * object. |
||
2573 | * |
||
2574 | * @param mixed $value |
||
2575 | * @param bool $checkForObjectIdentity |
||
2576 | * @param bool $checkForNonObjectIdentity |
||
2577 | * |
||
2578 | * @return PHPUnit_Framework_Constraint_TraversableContains |
||
2579 | * |
||
2580 | * @since Method available since Release 3.0.0 |
||
2581 | */ |
||
2582 | public static function contains($value, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
||
2586 | |||
2587 | /** |
||
2588 | * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher |
||
2589 | * object. |
||
2590 | * |
||
2591 | * @param string $type |
||
2592 | * |
||
2593 | * @return PHPUnit_Framework_Constraint_TraversableContainsOnly |
||
2594 | * |
||
2595 | * @since Method available since Release 3.1.4 |
||
2596 | */ |
||
2597 | public static function containsOnly($type) |
||
2601 | |||
2602 | /** |
||
2603 | * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher |
||
2604 | * object. |
||
2605 | * |
||
2606 | * @param string $classname |
||
2607 | * |
||
2608 | * @return PHPUnit_Framework_Constraint_TraversableContainsOnly |
||
2609 | */ |
||
2610 | public static function containsOnlyInstancesOf($classname) |
||
2614 | |||
2615 | /** |
||
2616 | * Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object. |
||
2617 | * |
||
2618 | * @param mixed $key |
||
2619 | * |
||
2620 | * @return PHPUnit_Framework_Constraint_ArrayHasKey |
||
2621 | * |
||
2622 | * @since Method available since Release 3.0.0 |
||
2623 | */ |
||
2624 | public static function arrayHasKey($key) |
||
2628 | |||
2629 | /** |
||
2630 | * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object. |
||
2631 | * |
||
2632 | * @param mixed $value |
||
2633 | * @param float $delta |
||
2634 | * @param int $maxDepth |
||
2635 | * @param bool $canonicalize |
||
2636 | * @param bool $ignoreCase |
||
2637 | * |
||
2638 | * @return PHPUnit_Framework_Constraint_IsEqual |
||
2639 | * |
||
2640 | * @since Method available since Release 3.0.0 |
||
2641 | */ |
||
2642 | public static function equalTo($value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
2652 | |||
2653 | /** |
||
2654 | * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object |
||
2655 | * that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher |
||
2656 | * object. |
||
2657 | * |
||
2658 | * @param string $attributeName |
||
2659 | * @param mixed $value |
||
2660 | * @param float $delta |
||
2661 | * @param int $maxDepth |
||
2662 | * @param bool $canonicalize |
||
2663 | * @param bool $ignoreCase |
||
2664 | * |
||
2665 | * @return PHPUnit_Framework_Constraint_Attribute |
||
2666 | * |
||
2667 | * @since Method available since Release 3.1.0 |
||
2668 | */ |
||
2669 | public static function attributeEqualTo($attributeName, $value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
2682 | |||
2683 | /** |
||
2684 | * Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object. |
||
2685 | * |
||
2686 | * @return PHPUnit_Framework_Constraint_IsEmpty |
||
2687 | * |
||
2688 | * @since Method available since Release 3.5.0 |
||
2689 | */ |
||
2690 | public static function isEmpty() |
||
2694 | |||
2695 | /** |
||
2696 | * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. |
||
2697 | * |
||
2698 | * @return PHPUnit_Framework_Constraint_FileExists |
||
2699 | * |
||
2700 | * @since Method available since Release 3.0.0 |
||
2701 | */ |
||
2702 | public static function fileExists() |
||
2706 | |||
2707 | /** |
||
2708 | * Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object. |
||
2709 | * |
||
2710 | * @param mixed $value |
||
2711 | * |
||
2712 | * @return PHPUnit_Framework_Constraint_GreaterThan |
||
2713 | * |
||
2714 | * @since Method available since Release 3.0.0 |
||
2715 | */ |
||
2716 | public static function greaterThan($value) |
||
2720 | |||
2721 | /** |
||
2722 | * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps |
||
2723 | * a PHPUnit_Framework_Constraint_IsEqual and a |
||
2724 | * PHPUnit_Framework_Constraint_GreaterThan matcher object. |
||
2725 | * |
||
2726 | * @param mixed $value |
||
2727 | * |
||
2728 | * @return PHPUnit_Framework_Constraint_Or |
||
2729 | * |
||
2730 | * @since Method available since Release 3.1.0 |
||
2731 | */ |
||
2732 | public static function greaterThanOrEqual($value) |
||
2739 | |||
2740 | /** |
||
2741 | * Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object. |
||
2742 | * |
||
2743 | * @param string $attributeName |
||
2744 | * |
||
2745 | * @return PHPUnit_Framework_Constraint_ClassHasAttribute |
||
2746 | * |
||
2747 | * @since Method available since Release 3.1.0 |
||
2748 | */ |
||
2749 | public static function classHasAttribute($attributeName) |
||
2755 | |||
2756 | /** |
||
2757 | * Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher |
||
2758 | * object. |
||
2759 | * |
||
2760 | * @param string $attributeName |
||
2761 | * |
||
2762 | * @return PHPUnit_Framework_Constraint_ClassHasStaticAttribute |
||
2763 | * |
||
2764 | * @since Method available since Release 3.1.0 |
||
2765 | */ |
||
2766 | public static function classHasStaticAttribute($attributeName) |
||
2772 | |||
2773 | /** |
||
2774 | * Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object. |
||
2775 | * |
||
2776 | * @param string $attributeName |
||
2777 | * |
||
2778 | * @return PHPUnit_Framework_Constraint_ObjectHasAttribute |
||
2779 | * |
||
2780 | * @since Method available since Release 3.0.0 |
||
2781 | */ |
||
2782 | public static function objectHasAttribute($attributeName) |
||
2788 | |||
2789 | /** |
||
2790 | * Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object. |
||
2791 | * |
||
2792 | * @param mixed $value |
||
2793 | * |
||
2794 | * @return PHPUnit_Framework_Constraint_IsIdentical |
||
2795 | * |
||
2796 | * @since Method available since Release 3.0.0 |
||
2797 | */ |
||
2798 | public static function identicalTo($value) |
||
2802 | |||
2803 | /** |
||
2804 | * Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object. |
||
2805 | * |
||
2806 | * @param string $className |
||
2807 | * |
||
2808 | * @return PHPUnit_Framework_Constraint_IsInstanceOf |
||
2809 | * |
||
2810 | * @since Method available since Release 3.0.0 |
||
2811 | */ |
||
2812 | public static function isInstanceOf($className) |
||
2816 | |||
2817 | /** |
||
2818 | * Returns a PHPUnit_Framework_Constraint_IsType matcher object. |
||
2819 | * |
||
2820 | * @param string $type |
||
2821 | * |
||
2822 | * @return PHPUnit_Framework_Constraint_IsType |
||
2823 | * |
||
2824 | * @since Method available since Release 3.0.0 |
||
2825 | */ |
||
2826 | public static function isType($type) |
||
2830 | |||
2831 | /** |
||
2832 | * Returns a PHPUnit_Framework_Constraint_LessThan matcher object. |
||
2833 | * |
||
2834 | * @param mixed $value |
||
2835 | * |
||
2836 | * @return PHPUnit_Framework_Constraint_LessThan |
||
2837 | * |
||
2838 | * @since Method available since Release 3.0.0 |
||
2839 | */ |
||
2840 | public static function lessThan($value) |
||
2844 | |||
2845 | /** |
||
2846 | * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps |
||
2847 | * a PHPUnit_Framework_Constraint_IsEqual and a |
||
2848 | * PHPUnit_Framework_Constraint_LessThan matcher object. |
||
2849 | * |
||
2850 | * @param mixed $value |
||
2851 | * |
||
2852 | * @return PHPUnit_Framework_Constraint_Or |
||
2853 | * |
||
2854 | * @since Method available since Release 3.1.0 |
||
2855 | */ |
||
2856 | public static function lessThanOrEqual($value) |
||
2863 | |||
2864 | /** |
||
2865 | * Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object. |
||
2866 | * |
||
2867 | * @param string $pattern |
||
2868 | * |
||
2869 | * @return PHPUnit_Framework_Constraint_PCREMatch |
||
2870 | * |
||
2871 | * @since Method available since Release 3.0.0 |
||
2872 | */ |
||
2873 | public static function matchesRegularExpression($pattern) |
||
2877 | |||
2878 | /** |
||
2879 | * Returns a PHPUnit_Framework_Constraint_StringMatches matcher object. |
||
2880 | * |
||
2881 | * @param string $string |
||
2882 | * |
||
2883 | * @return PHPUnit_Framework_Constraint_StringMatches |
||
2884 | * |
||
2885 | * @since Method available since Release 3.5.0 |
||
2886 | */ |
||
2887 | public static function matches($string) |
||
2891 | |||
2892 | /** |
||
2893 | * Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object. |
||
2894 | * |
||
2895 | * @param mixed $prefix |
||
2896 | * |
||
2897 | * @return PHPUnit_Framework_Constraint_StringStartsWith |
||
2898 | * |
||
2899 | * @since Method available since Release 3.4.0 |
||
2900 | */ |
||
2901 | public static function stringStartsWith($prefix) |
||
2905 | |||
2906 | /** |
||
2907 | * Returns a PHPUnit_Framework_Constraint_StringContains matcher object. |
||
2908 | * |
||
2909 | * @param string $string |
||
2910 | * @param bool $case |
||
2911 | * |
||
2912 | * @return PHPUnit_Framework_Constraint_StringContains |
||
2913 | * |
||
2914 | * @since Method available since Release 3.0.0 |
||
2915 | */ |
||
2916 | public static function stringContains($string, $case = true) |
||
2920 | |||
2921 | /** |
||
2922 | * Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object. |
||
2923 | * |
||
2924 | * @param mixed $suffix |
||
2925 | * |
||
2926 | * @return PHPUnit_Framework_Constraint_StringEndsWith |
||
2927 | * |
||
2928 | * @since Method available since Release 3.4.0 |
||
2929 | */ |
||
2930 | public static function stringEndsWith($suffix) |
||
2934 | |||
2935 | /** |
||
2936 | * Returns a PHPUnit_Framework_Constraint_Count matcher object. |
||
2937 | * |
||
2938 | * @param int $count |
||
2939 | * |
||
2940 | * @return PHPUnit_Framework_Constraint_Count |
||
2941 | */ |
||
2942 | public static function countOf($count) |
||
2946 | /** |
||
2947 | * Fails a test with the given message. |
||
2948 | * |
||
2949 | * @param string $message |
||
2950 | * |
||
2951 | * @throws PHPUnit_Framework_AssertionFailedError |
||
2952 | */ |
||
2953 | public static function fail($message = '') |
||
2957 | |||
2958 | /** |
||
2959 | * Returns the value of an attribute of a class or an object. |
||
2960 | * This also works for attributes that are declared protected or private. |
||
2961 | * |
||
2962 | * @param mixed $classOrObject |
||
2963 | * @param string $attributeName |
||
2964 | * |
||
2965 | * @return mixed |
||
2966 | * |
||
2967 | * @throws PHPUnit_Framework_Exception |
||
2968 | */ |
||
2969 | public static function readAttribute($classOrObject, $attributeName) |
||
3003 | |||
3004 | /** |
||
3005 | * Returns the value of a static attribute. |
||
3006 | * This also works for attributes that are declared protected or private. |
||
3007 | * |
||
3008 | * @param string $className |
||
3009 | * @param string $attributeName |
||
3010 | * |
||
3011 | * @return mixed |
||
3012 | * |
||
3013 | * @throws PHPUnit_Framework_Exception |
||
3014 | * |
||
3015 | * @since Method available since Release 4.0.0 |
||
3016 | */ |
||
3017 | public static function getStaticAttribute($className, $attributeName) |
||
3054 | |||
3055 | /** |
||
3056 | * Returns the value of an object's attribute. |
||
3057 | * This also works for attributes that are declared protected or private. |
||
3058 | * |
||
3059 | * @param object $object |
||
3060 | * @param string $attributeName |
||
3061 | * |
||
3062 | * @return mixed |
||
3063 | * |
||
3064 | * @throws PHPUnit_Framework_Exception |
||
3065 | * |
||
3066 | * @since Method available since Release 4.0.0 |
||
3067 | */ |
||
3068 | public static function getObjectAttribute($object, $attributeName) |
||
3115 | |||
3116 | /** |
||
3117 | * Mark the test as incomplete. |
||
3118 | * |
||
3119 | * @param string $message |
||
3120 | * |
||
3121 | * @throws PHPUnit_Framework_IncompleteTestError |
||
3122 | * |
||
3123 | * @since Method available since Release 3.0.0 |
||
3124 | */ |
||
3125 | public static function markTestIncomplete($message = '') |
||
3129 | |||
3130 | /** |
||
3131 | * Mark the test as skipped. |
||
3132 | * |
||
3133 | * @param string $message |
||
3134 | * |
||
3135 | * @throws PHPUnit_Framework_SkippedTestError |
||
3136 | * |
||
3137 | * @since Method available since Release 3.0.0 |
||
3138 | */ |
||
3139 | public static function markTestSkipped($message = '') |
||
3143 | |||
3144 | /** |
||
3145 | * Return the current assertion count. |
||
3146 | * |
||
3147 | * @return int |
||
3148 | * |
||
3149 | * @since Method available since Release 3.3.3 |
||
3150 | */ |
||
3151 | public static function getCount() |
||
3155 | |||
3156 | /** |
||
3157 | * Reset the assertion counter. |
||
3158 | * |
||
3159 | * @since Method available since Release 3.3.3 |
||
3160 | */ |
||
3161 | public static function resetCount() |
||
3165 | } |
||
3166 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.