Complex classes like 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 Assert, and based on these observations, apply Extract Interface, too.
1 | <?php declare(strict_types=1); |
||
70 | abstract class Assert |
||
71 | { |
||
72 | /** |
||
73 | * @var int |
||
74 | */ |
||
75 | private static $count = 0; |
||
76 | |||
77 | /** |
||
78 | * Asserts that an array has a specified key. |
||
79 | * |
||
80 | * @param int|string $key |
||
81 | * @param array|ArrayAccess $array |
||
82 | * |
||
83 | * @throws ExpectationFailedException |
||
84 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
85 | * @throws Exception |
||
86 | */ |
||
87 | public static function assertArrayHasKey($key, $array, string $message = ''): void |
||
107 | |||
108 | /** |
||
109 | * Asserts that an array has a specified subset. |
||
110 | * |
||
111 | * @param array|ArrayAccess $subset |
||
112 | * @param array|ArrayAccess $array |
||
113 | * |
||
114 | * @throws ExpectationFailedException |
||
115 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
116 | * @throws Exception |
||
117 | * |
||
118 | * @codeCoverageIgnore |
||
119 | * |
||
120 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3494 |
||
121 | */ |
||
122 | public static function assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = ''): void |
||
144 | |||
145 | /** |
||
146 | * Asserts that an array does not have a specified key. |
||
147 | * |
||
148 | * @param int|string $key |
||
149 | * @param array|ArrayAccess $array |
||
150 | * |
||
151 | * @throws ExpectationFailedException |
||
152 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
153 | * @throws Exception |
||
154 | */ |
||
155 | public static function assertArrayNotHasKey($key, $array, string $message = ''): void |
||
177 | |||
178 | /** |
||
179 | * Asserts that a haystack contains a needle. |
||
180 | * |
||
181 | * @throws ExpectationFailedException |
||
182 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
183 | * @throws Exception |
||
184 | */ |
||
185 | public static function assertContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void |
||
233 | |||
234 | public static function assertContainsEquals($needle, iterable $haystack, string $message = ''): void |
||
240 | |||
241 | /** |
||
242 | * Asserts that a haystack that is stored in a static attribute of a class |
||
243 | * or an attribute of an object contains a needle. |
||
244 | * |
||
245 | * @param object|string $haystackClassOrObject |
||
246 | * |
||
247 | * @throws ExpectationFailedException |
||
248 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
249 | * @throws ReflectionException |
||
250 | * @throws Exception |
||
251 | * |
||
252 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
253 | * @codeCoverageIgnore |
||
254 | */ |
||
255 | public static function assertAttributeContains($needle, string $haystackAttributeName, $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void |
||
268 | |||
269 | /** |
||
270 | * Asserts that a haystack does not contain a needle. |
||
271 | * |
||
272 | * @throws ExpectationFailedException |
||
273 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
274 | * @throws Exception |
||
275 | */ |
||
276 | public static function assertNotContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void |
||
328 | |||
329 | public static function assertNotContainsEquals($needle, iterable $haystack, string $message = ''): void |
||
335 | |||
336 | /** |
||
337 | * Asserts that a haystack that is stored in a static attribute of a class |
||
338 | * or an attribute of an object does not contain a needle. |
||
339 | * |
||
340 | * @param object|string $haystackClassOrObject |
||
341 | * |
||
342 | * @throws ExpectationFailedException |
||
343 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
344 | * @throws ReflectionException |
||
345 | * @throws Exception |
||
346 | * |
||
347 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
348 | * @codeCoverageIgnore |
||
349 | */ |
||
350 | public static function assertAttributeNotContains($needle, string $haystackAttributeName, $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void |
||
363 | |||
364 | /** |
||
365 | * Asserts that a haystack contains only values of a given type. |
||
366 | * |
||
367 | * @throws ExpectationFailedException |
||
368 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
369 | */ |
||
370 | public static function assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void |
||
385 | |||
386 | /** |
||
387 | * Asserts that a haystack contains only instances of a given class name. |
||
388 | * |
||
389 | * @throws ExpectationFailedException |
||
390 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
391 | */ |
||
392 | public static function assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void |
||
403 | |||
404 | /** |
||
405 | * Asserts that a haystack that is stored in a static attribute of a class |
||
406 | * or an attribute of an object contains only values of a given type. |
||
407 | * |
||
408 | * @param object|string $haystackClassOrObject |
||
409 | * @param bool $isNativeType |
||
410 | * |
||
411 | * @throws ExpectationFailedException |
||
412 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
413 | * @throws ReflectionException |
||
414 | * @throws Exception |
||
415 | * |
||
416 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
417 | * @codeCoverageIgnore |
||
418 | */ |
||
419 | public static function assertAttributeContainsOnly(string $type, string $haystackAttributeName, $haystackClassOrObject, ?bool $isNativeType = null, string $message = ''): void |
||
430 | |||
431 | /** |
||
432 | * Asserts that a haystack does not contain only values of a given type. |
||
433 | * |
||
434 | * @throws ExpectationFailedException |
||
435 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
436 | */ |
||
437 | public static function assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void |
||
454 | |||
455 | /** |
||
456 | * Asserts that a haystack that is stored in a static attribute of a class |
||
457 | * or an attribute of an object does not contain only values of a given |
||
458 | * type. |
||
459 | * |
||
460 | * @param object|string $haystackClassOrObject |
||
461 | * @param bool $isNativeType |
||
462 | * |
||
463 | * @throws ExpectationFailedException |
||
464 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
465 | * @throws ReflectionException |
||
466 | * @throws Exception |
||
467 | * |
||
468 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
469 | * @codeCoverageIgnore |
||
470 | */ |
||
471 | public static function assertAttributeNotContainsOnly(string $type, string $haystackAttributeName, $haystackClassOrObject, ?bool $isNativeType = null, string $message = ''): void |
||
482 | |||
483 | /** |
||
484 | * Asserts the number of elements of an array, Countable or Traversable. |
||
485 | * |
||
486 | * @param Countable|iterable $haystack |
||
487 | * |
||
488 | * @throws ExpectationFailedException |
||
489 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
490 | * @throws Exception |
||
491 | */ |
||
492 | public static function assertCount(int $expectedCount, $haystack, string $message = ''): void |
||
504 | |||
505 | /** |
||
506 | * Asserts the number of elements of an array, Countable or Traversable |
||
507 | * that is stored in an attribute. |
||
508 | * |
||
509 | * @param object|string $haystackClassOrObject |
||
510 | * |
||
511 | * @throws ExpectationFailedException |
||
512 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
513 | * @throws ReflectionException |
||
514 | * @throws Exception |
||
515 | * |
||
516 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
517 | * @codeCoverageIgnore |
||
518 | */ |
||
519 | public static function assertAttributeCount(int $expectedCount, string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void |
||
529 | |||
530 | /** |
||
531 | * Asserts the number of elements of an array, Countable or Traversable. |
||
532 | * |
||
533 | * @param Countable|iterable $haystack |
||
534 | * |
||
535 | * @throws ExpectationFailedException |
||
536 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
537 | * @throws Exception |
||
538 | */ |
||
539 | public static function assertNotCount(int $expectedCount, $haystack, string $message = ''): void |
||
551 | |||
552 | /** |
||
553 | * Asserts the number of elements of an array, Countable or Traversable |
||
554 | * that is stored in an attribute. |
||
555 | * |
||
556 | * @param object|string $haystackClassOrObject |
||
557 | * |
||
558 | * @throws ExpectationFailedException |
||
559 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
560 | * @throws ReflectionException |
||
561 | * @throws Exception |
||
562 | * |
||
563 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
564 | * @codeCoverageIgnore |
||
565 | */ |
||
566 | public static function assertAttributeNotCount(int $expectedCount, string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void |
||
576 | |||
577 | /** |
||
578 | * Asserts that two variables are equal. |
||
579 | * |
||
580 | * @throws ExpectationFailedException |
||
581 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
582 | */ |
||
583 | public static function assertEquals($expected, $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void |
||
613 | |||
614 | /** |
||
615 | * Asserts that two variables are equal (canonicalizing). |
||
616 | * |
||
617 | * @throws ExpectationFailedException |
||
618 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
619 | */ |
||
620 | public static function assertEqualsCanonicalizing($expected, $actual, string $message = ''): void |
||
632 | |||
633 | /** |
||
634 | * Asserts that two variables are equal (ignoring case). |
||
635 | * |
||
636 | * @throws ExpectationFailedException |
||
637 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
638 | */ |
||
639 | public static function assertEqualsIgnoringCase($expected, $actual, string $message = ''): void |
||
651 | |||
652 | /** |
||
653 | * Asserts that two variables are equal (with delta). |
||
654 | * |
||
655 | * @throws ExpectationFailedException |
||
656 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
657 | */ |
||
658 | public static function assertEqualsWithDelta($expected, $actual, float $delta, string $message = ''): void |
||
667 | |||
668 | /** |
||
669 | * Asserts that a variable is equal to an attribute of an object. |
||
670 | * |
||
671 | * @param object|string $actualClassOrObject |
||
672 | * |
||
673 | * @throws ExpectationFailedException |
||
674 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
675 | * @throws ReflectionException |
||
676 | * @throws Exception |
||
677 | * |
||
678 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
679 | * @codeCoverageIgnore |
||
680 | */ |
||
681 | public static function assertAttributeEquals($expected, string $actualAttributeName, $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void |
||
695 | |||
696 | /** |
||
697 | * Asserts that two variables are not equal. |
||
698 | * |
||
699 | * @param float $delta |
||
700 | * @param int $maxDepth |
||
701 | * @param bool $canonicalize |
||
702 | * @param bool $ignoreCase |
||
703 | * |
||
704 | * @throws ExpectationFailedException |
||
705 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
706 | */ |
||
707 | public static function assertNotEquals($expected, $actual, string $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false): void |
||
739 | |||
740 | /** |
||
741 | * Asserts that two variables are not equal (canonicalizing). |
||
742 | * |
||
743 | * @throws ExpectationFailedException |
||
744 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
745 | */ |
||
746 | public static function assertNotEqualsCanonicalizing($expected, $actual, string $message = ''): void |
||
760 | |||
761 | /** |
||
762 | * Asserts that two variables are not equal (ignoring case). |
||
763 | * |
||
764 | * @throws ExpectationFailedException |
||
765 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
766 | */ |
||
767 | public static function assertNotEqualsIgnoringCase($expected, $actual, string $message = ''): void |
||
781 | |||
782 | /** |
||
783 | * Asserts that two variables are not equal (with delta). |
||
784 | * |
||
785 | * @throws ExpectationFailedException |
||
786 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
787 | */ |
||
788 | public static function assertNotEqualsWithDelta($expected, $actual, float $delta, string $message = ''): void |
||
799 | |||
800 | /** |
||
801 | * Asserts that a variable is not equal to an attribute of an object. |
||
802 | * |
||
803 | * @param object|string $actualClassOrObject |
||
804 | * |
||
805 | * @throws ExpectationFailedException |
||
806 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
807 | * @throws ReflectionException |
||
808 | * @throws Exception |
||
809 | * |
||
810 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
811 | * @codeCoverageIgnore |
||
812 | */ |
||
813 | public static function assertAttributeNotEquals($expected, string $actualAttributeName, $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void |
||
827 | |||
828 | /** |
||
829 | * Asserts that a variable is empty. |
||
830 | * |
||
831 | * @throws ExpectationFailedException |
||
832 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
833 | */ |
||
834 | public static function assertEmpty($actual, string $message = ''): void |
||
838 | |||
839 | /** |
||
840 | * Asserts that a static attribute of a class or an attribute of an object |
||
841 | * is empty. |
||
842 | * |
||
843 | * @param object|string $haystackClassOrObject |
||
844 | * |
||
845 | * @throws ExpectationFailedException |
||
846 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
847 | * @throws ReflectionException |
||
848 | * @throws Exception |
||
849 | * |
||
850 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
851 | * @codeCoverageIgnore |
||
852 | */ |
||
853 | public static function assertAttributeEmpty(string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void |
||
862 | |||
863 | /** |
||
864 | * Asserts that a variable is not empty. |
||
865 | * |
||
866 | * @throws ExpectationFailedException |
||
867 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
868 | */ |
||
869 | public static function assertNotEmpty($actual, string $message = ''): void |
||
873 | |||
874 | /** |
||
875 | * Asserts that a static attribute of a class or an attribute of an object |
||
876 | * is not empty. |
||
877 | * |
||
878 | * @param object|string $haystackClassOrObject |
||
879 | * |
||
880 | * @throws ExpectationFailedException |
||
881 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
882 | * @throws ReflectionException |
||
883 | * @throws Exception |
||
884 | * |
||
885 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
886 | * @codeCoverageIgnore |
||
887 | */ |
||
888 | public static function assertAttributeNotEmpty(string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void |
||
897 | |||
898 | /** |
||
899 | * Asserts that a value is greater than another value. |
||
900 | * |
||
901 | * @throws ExpectationFailedException |
||
902 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
903 | */ |
||
904 | public static function assertGreaterThan($expected, $actual, string $message = ''): void |
||
908 | |||
909 | /** |
||
910 | * Asserts that an attribute is greater than another value. |
||
911 | * |
||
912 | * @param object|string $actualClassOrObject |
||
913 | * |
||
914 | * @throws ExpectationFailedException |
||
915 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
916 | * @throws ReflectionException |
||
917 | * @throws Exception |
||
918 | * |
||
919 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
920 | * @codeCoverageIgnore |
||
921 | */ |
||
922 | public static function assertAttributeGreaterThan($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void |
||
932 | |||
933 | /** |
||
934 | * Asserts that a value is greater than or equal to another value. |
||
935 | * |
||
936 | * @throws ExpectationFailedException |
||
937 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
938 | */ |
||
939 | public static function assertGreaterThanOrEqual($expected, $actual, string $message = ''): void |
||
947 | |||
948 | /** |
||
949 | * Asserts that an attribute is greater than or equal to another value. |
||
950 | * |
||
951 | * @param object|string $actualClassOrObject |
||
952 | * |
||
953 | * @throws ExpectationFailedException |
||
954 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
955 | * @throws ReflectionException |
||
956 | * @throws Exception |
||
957 | * |
||
958 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
959 | * @codeCoverageIgnore |
||
960 | */ |
||
961 | public static function assertAttributeGreaterThanOrEqual($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void |
||
971 | |||
972 | /** |
||
973 | * Asserts that a value is smaller than another value. |
||
974 | * |
||
975 | * @throws ExpectationFailedException |
||
976 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
977 | */ |
||
978 | public static function assertLessThan($expected, $actual, string $message = ''): void |
||
982 | |||
983 | /** |
||
984 | * Asserts that an attribute is smaller than another value. |
||
985 | * |
||
986 | * @param object|string $actualClassOrObject |
||
987 | * |
||
988 | * @throws ExpectationFailedException |
||
989 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
990 | * @throws ReflectionException |
||
991 | * @throws Exception |
||
992 | * |
||
993 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
994 | * @codeCoverageIgnore |
||
995 | */ |
||
996 | public static function assertAttributeLessThan($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void |
||
1006 | |||
1007 | /** |
||
1008 | * Asserts that a value is smaller than or equal to another value. |
||
1009 | * |
||
1010 | * @throws ExpectationFailedException |
||
1011 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1012 | */ |
||
1013 | public static function assertLessThanOrEqual($expected, $actual, string $message = ''): void |
||
1017 | |||
1018 | /** |
||
1019 | * Asserts that an attribute is smaller than or equal to another value. |
||
1020 | * |
||
1021 | * @param object|string $actualClassOrObject |
||
1022 | * |
||
1023 | * @throws ExpectationFailedException |
||
1024 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1025 | * @throws ReflectionException |
||
1026 | * @throws Exception |
||
1027 | * |
||
1028 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
1029 | * @codeCoverageIgnore |
||
1030 | */ |
||
1031 | public static function assertAttributeLessThanOrEqual($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void |
||
1041 | |||
1042 | /** |
||
1043 | * Asserts that the contents of one file is equal to the contents of another |
||
1044 | * file. |
||
1045 | * |
||
1046 | * @throws ExpectationFailedException |
||
1047 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1048 | */ |
||
1049 | public static function assertFileEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void |
||
1064 | |||
1065 | /** |
||
1066 | * Asserts that the contents of one file is not equal to the contents of |
||
1067 | * another file. |
||
1068 | * |
||
1069 | * @throws ExpectationFailedException |
||
1070 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1071 | */ |
||
1072 | public static function assertFileNotEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void |
||
1089 | |||
1090 | /** |
||
1091 | * Asserts that the contents of a string is equal |
||
1092 | * to the contents of a file. |
||
1093 | * |
||
1094 | * @throws ExpectationFailedException |
||
1095 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1096 | */ |
||
1097 | public static function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void |
||
1111 | |||
1112 | /** |
||
1113 | * Asserts that the contents of a string is not equal |
||
1114 | * to the contents of a file. |
||
1115 | * |
||
1116 | * @throws ExpectationFailedException |
||
1117 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1118 | */ |
||
1119 | public static function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void |
||
1135 | |||
1136 | /** |
||
1137 | * Asserts that a file/dir is readable. |
||
1138 | * |
||
1139 | * @throws ExpectationFailedException |
||
1140 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1141 | */ |
||
1142 | public static function assertIsReadable(string $filename, string $message = ''): void |
||
1146 | |||
1147 | /** |
||
1148 | * Asserts that a file/dir exists and is not readable. |
||
1149 | * |
||
1150 | * @throws ExpectationFailedException |
||
1151 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1152 | */ |
||
1153 | public static function assertNotIsReadable(string $filename, string $message = ''): void |
||
1157 | |||
1158 | /** |
||
1159 | * Asserts that a file/dir exists and is writable. |
||
1160 | * |
||
1161 | * @throws ExpectationFailedException |
||
1162 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1163 | */ |
||
1164 | public static function assertIsWritable(string $filename, string $message = ''): void |
||
1168 | |||
1169 | /** |
||
1170 | * Asserts that a file/dir exists and is not writable. |
||
1171 | * |
||
1172 | * @throws ExpectationFailedException |
||
1173 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1174 | */ |
||
1175 | public static function assertNotIsWritable(string $filename, string $message = ''): void |
||
1179 | |||
1180 | /** |
||
1181 | * Asserts that a directory exists. |
||
1182 | * |
||
1183 | * @throws ExpectationFailedException |
||
1184 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1185 | */ |
||
1186 | public static function assertDirectoryExists(string $directory, string $message = ''): void |
||
1190 | |||
1191 | /** |
||
1192 | * Asserts that a directory does not exist. |
||
1193 | * |
||
1194 | * @throws ExpectationFailedException |
||
1195 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1196 | */ |
||
1197 | public static function assertDirectoryNotExists(string $directory, string $message = ''): void |
||
1201 | |||
1202 | /** |
||
1203 | * Asserts that a directory exists and is readable. |
||
1204 | * |
||
1205 | * @throws ExpectationFailedException |
||
1206 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1207 | */ |
||
1208 | public static function assertDirectoryIsReadable(string $directory, string $message = ''): void |
||
1213 | |||
1214 | /** |
||
1215 | * Asserts that a directory exists and is not readable. |
||
1216 | * |
||
1217 | * @throws ExpectationFailedException |
||
1218 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1219 | */ |
||
1220 | public static function assertDirectoryNotIsReadable(string $directory, string $message = ''): void |
||
1225 | |||
1226 | /** |
||
1227 | * Asserts that a directory exists and is writable. |
||
1228 | * |
||
1229 | * @throws ExpectationFailedException |
||
1230 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1231 | */ |
||
1232 | public static function assertDirectoryIsWritable(string $directory, string $message = ''): void |
||
1237 | |||
1238 | /** |
||
1239 | * Asserts that a directory exists and is not writable. |
||
1240 | * |
||
1241 | * @throws ExpectationFailedException |
||
1242 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1243 | */ |
||
1244 | public static function assertDirectoryNotIsWritable(string $directory, string $message = ''): void |
||
1249 | |||
1250 | /** |
||
1251 | * Asserts that a file exists. |
||
1252 | * |
||
1253 | * @throws ExpectationFailedException |
||
1254 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1255 | */ |
||
1256 | public static function assertFileExists(string $filename, string $message = ''): void |
||
1260 | |||
1261 | /** |
||
1262 | * Asserts that a file does not exist. |
||
1263 | * |
||
1264 | * @throws ExpectationFailedException |
||
1265 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1266 | */ |
||
1267 | public static function assertFileNotExists(string $filename, string $message = ''): void |
||
1271 | |||
1272 | /** |
||
1273 | * Asserts that a file exists and is readable. |
||
1274 | * |
||
1275 | * @throws ExpectationFailedException |
||
1276 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1277 | */ |
||
1278 | public static function assertFileIsReadable(string $file, string $message = ''): void |
||
1283 | |||
1284 | /** |
||
1285 | * Asserts that a file exists and is not readable. |
||
1286 | * |
||
1287 | * @throws ExpectationFailedException |
||
1288 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1289 | */ |
||
1290 | public static function assertFileNotIsReadable(string $file, string $message = ''): void |
||
1295 | |||
1296 | /** |
||
1297 | * Asserts that a file exists and is writable. |
||
1298 | * |
||
1299 | * @throws ExpectationFailedException |
||
1300 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1301 | */ |
||
1302 | public static function assertFileIsWritable(string $file, string $message = ''): void |
||
1307 | |||
1308 | /** |
||
1309 | * Asserts that a file exists and is not writable. |
||
1310 | * |
||
1311 | * @throws ExpectationFailedException |
||
1312 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1313 | */ |
||
1314 | public static function assertFileNotIsWritable(string $file, string $message = ''): void |
||
1319 | |||
1320 | /** |
||
1321 | * Asserts that a condition is true. |
||
1322 | * |
||
1323 | * @throws ExpectationFailedException |
||
1324 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1325 | */ |
||
1326 | public static function assertTrue($condition, string $message = ''): void |
||
1330 | |||
1331 | /** |
||
1332 | * Asserts that a condition is not true. |
||
1333 | * |
||
1334 | * @throws ExpectationFailedException |
||
1335 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1336 | */ |
||
1337 | public static function assertNotTrue($condition, string $message = ''): void |
||
1341 | |||
1342 | /** |
||
1343 | * Asserts that a condition is false. |
||
1344 | * |
||
1345 | * @throws ExpectationFailedException |
||
1346 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1347 | */ |
||
1348 | public static function assertFalse($condition, string $message = ''): void |
||
1352 | |||
1353 | /** |
||
1354 | * Asserts that a condition is not false. |
||
1355 | * |
||
1356 | * @throws ExpectationFailedException |
||
1357 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1358 | */ |
||
1359 | public static function assertNotFalse($condition, string $message = ''): void |
||
1363 | |||
1364 | /** |
||
1365 | * Asserts that a variable is null. |
||
1366 | * |
||
1367 | * @throws ExpectationFailedException |
||
1368 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1369 | */ |
||
1370 | public static function assertNull($actual, string $message = ''): void |
||
1374 | |||
1375 | /** |
||
1376 | * Asserts that a variable is not null. |
||
1377 | * |
||
1378 | * @throws ExpectationFailedException |
||
1379 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1380 | */ |
||
1381 | public static function assertNotNull($actual, string $message = ''): void |
||
1385 | |||
1386 | /** |
||
1387 | * Asserts that a variable is finite. |
||
1388 | * |
||
1389 | * @throws ExpectationFailedException |
||
1390 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1391 | */ |
||
1392 | public static function assertFinite($actual, string $message = ''): void |
||
1396 | |||
1397 | /** |
||
1398 | * Asserts that a variable is infinite. |
||
1399 | * |
||
1400 | * @throws ExpectationFailedException |
||
1401 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1402 | */ |
||
1403 | public static function assertInfinite($actual, string $message = ''): void |
||
1407 | |||
1408 | /** |
||
1409 | * Asserts that a variable is nan. |
||
1410 | * |
||
1411 | * @throws ExpectationFailedException |
||
1412 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1413 | */ |
||
1414 | public static function assertNan($actual, string $message = ''): void |
||
1418 | |||
1419 | /** |
||
1420 | * Asserts that a class has a specified attribute. |
||
1421 | * |
||
1422 | * @throws ExpectationFailedException |
||
1423 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1424 | * @throws Exception |
||
1425 | */ |
||
1426 | public static function assertClassHasAttribute(string $attributeName, string $className, string $message = ''): void |
||
1438 | |||
1439 | /** |
||
1440 | * Asserts that a class does not have a specified attribute. |
||
1441 | * |
||
1442 | * @throws ExpectationFailedException |
||
1443 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1444 | * @throws Exception |
||
1445 | */ |
||
1446 | public static function assertClassNotHasAttribute(string $attributeName, string $className, string $message = ''): void |
||
1464 | |||
1465 | /** |
||
1466 | * Asserts that a class has a specified static attribute. |
||
1467 | * |
||
1468 | * @throws ExpectationFailedException |
||
1469 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1470 | * @throws Exception |
||
1471 | */ |
||
1472 | public static function assertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void |
||
1488 | |||
1489 | /** |
||
1490 | * Asserts that a class does not have a specified static attribute. |
||
1491 | * |
||
1492 | * @throws ExpectationFailedException |
||
1493 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1494 | * @throws Exception |
||
1495 | */ |
||
1496 | public static function assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void |
||
1514 | |||
1515 | /** |
||
1516 | * Asserts that an object has a specified attribute. |
||
1517 | * |
||
1518 | * @param object $object |
||
1519 | * |
||
1520 | * @throws ExpectationFailedException |
||
1521 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1522 | * @throws Exception |
||
1523 | */ |
||
1524 | public static function assertObjectHasAttribute(string $attributeName, $object, string $message = ''): void |
||
1540 | |||
1541 | /** |
||
1542 | * Asserts that an object does not have a specified attribute. |
||
1543 | * |
||
1544 | * @param object $object |
||
1545 | * |
||
1546 | * @throws ExpectationFailedException |
||
1547 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1548 | * @throws Exception |
||
1549 | */ |
||
1550 | public static function assertObjectNotHasAttribute(string $attributeName, $object, string $message = ''): void |
||
1568 | |||
1569 | /** |
||
1570 | * Asserts that two variables have the same type and value. |
||
1571 | * Used on objects, it asserts that two variables reference |
||
1572 | * the same object. |
||
1573 | * |
||
1574 | * @throws ExpectationFailedException |
||
1575 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1576 | */ |
||
1577 | public static function assertSame($expected, $actual, string $message = ''): void |
||
1585 | |||
1586 | /** |
||
1587 | * Asserts that a variable and an attribute of an object have the same type |
||
1588 | * and value. |
||
1589 | * |
||
1590 | * @param object|string $actualClassOrObject |
||
1591 | * |
||
1592 | * @throws ExpectationFailedException |
||
1593 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1594 | * @throws ReflectionException |
||
1595 | * @throws Exception |
||
1596 | * |
||
1597 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
1598 | * @codeCoverageIgnore |
||
1599 | */ |
||
1600 | public static function assertAttributeSame($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void |
||
1610 | |||
1611 | /** |
||
1612 | * Asserts that two variables do not have the same type and value. |
||
1613 | * Used on objects, it asserts that two variables do not reference |
||
1614 | * the same object. |
||
1615 | * |
||
1616 | * @throws ExpectationFailedException |
||
1617 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1618 | */ |
||
1619 | public static function assertNotSame($expected, $actual, string $message = ''): void |
||
1633 | |||
1634 | /** |
||
1635 | * Asserts that a variable and an attribute of an object do not have the |
||
1636 | * same type and value. |
||
1637 | * |
||
1638 | * @param object|string $actualClassOrObject |
||
1639 | * |
||
1640 | * @throws ExpectationFailedException |
||
1641 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1642 | * @throws ReflectionException |
||
1643 | * @throws Exception |
||
1644 | * |
||
1645 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
1646 | * @codeCoverageIgnore |
||
1647 | */ |
||
1648 | public static function assertAttributeNotSame($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void |
||
1658 | |||
1659 | /** |
||
1660 | * Asserts that a variable is of a given type. |
||
1661 | * |
||
1662 | * @throws ExpectationFailedException |
||
1663 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1664 | * @throws Exception |
||
1665 | */ |
||
1666 | public static function assertInstanceOf(string $expected, $actual, string $message = ''): void |
||
1678 | |||
1679 | /** |
||
1680 | * Asserts that an attribute is of a given type. |
||
1681 | * |
||
1682 | * @param object|string $classOrObject |
||
1683 | * |
||
1684 | * @throws ExpectationFailedException |
||
1685 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1686 | * @throws ReflectionException |
||
1687 | * @throws Exception |
||
1688 | * |
||
1689 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
1690 | * @codeCoverageIgnore |
||
1691 | */ |
||
1692 | public static function assertAttributeInstanceOf(string $expected, string $attributeName, $classOrObject, string $message = ''): void |
||
1702 | |||
1703 | /** |
||
1704 | * Asserts that a variable is not of a given type. |
||
1705 | * |
||
1706 | * @throws ExpectationFailedException |
||
1707 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1708 | * @throws Exception |
||
1709 | */ |
||
1710 | public static function assertNotInstanceOf(string $expected, $actual, string $message = ''): void |
||
1724 | |||
1725 | /** |
||
1726 | * Asserts that an attribute is of a given type. |
||
1727 | * |
||
1728 | * @param object|string $classOrObject |
||
1729 | * |
||
1730 | * @throws ExpectationFailedException |
||
1731 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1732 | * @throws ReflectionException |
||
1733 | * @throws Exception |
||
1734 | * |
||
1735 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
1736 | * @codeCoverageIgnore |
||
1737 | */ |
||
1738 | public static function assertAttributeNotInstanceOf(string $expected, string $attributeName, $classOrObject, string $message = ''): void |
||
1748 | |||
1749 | /** |
||
1750 | * Asserts that a variable is of a given type. |
||
1751 | * |
||
1752 | * @throws ExpectationFailedException |
||
1753 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1754 | * |
||
1755 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3369 |
||
1756 | * @codeCoverageIgnore |
||
1757 | */ |
||
1758 | public static function assertInternalType(string $expected, $actual, string $message = ''): void |
||
1768 | |||
1769 | /** |
||
1770 | * Asserts that an attribute is of a given type. |
||
1771 | * |
||
1772 | * @param object|string $classOrObject |
||
1773 | * |
||
1774 | * @throws ExpectationFailedException |
||
1775 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1776 | * @throws ReflectionException |
||
1777 | * @throws Exception |
||
1778 | * |
||
1779 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
1780 | * @codeCoverageIgnore |
||
1781 | */ |
||
1782 | public static function assertAttributeInternalType(string $expected, string $attributeName, $classOrObject, string $message = ''): void |
||
1792 | |||
1793 | /** |
||
1794 | * Asserts that a variable is of type array. |
||
1795 | * |
||
1796 | * @throws ExpectationFailedException |
||
1797 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1798 | */ |
||
1799 | public static function assertIsArray($actual, string $message = ''): void |
||
1807 | |||
1808 | /** |
||
1809 | * Asserts that a variable is of type bool. |
||
1810 | * |
||
1811 | * @throws ExpectationFailedException |
||
1812 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1813 | */ |
||
1814 | public static function assertIsBool($actual, string $message = ''): void |
||
1822 | |||
1823 | /** |
||
1824 | * Asserts that a variable is of type float. |
||
1825 | * |
||
1826 | * @throws ExpectationFailedException |
||
1827 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1828 | */ |
||
1829 | public static function assertIsFloat($actual, string $message = ''): void |
||
1837 | |||
1838 | /** |
||
1839 | * Asserts that a variable is of type int. |
||
1840 | * |
||
1841 | * @throws ExpectationFailedException |
||
1842 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1843 | */ |
||
1844 | public static function assertIsInt($actual, string $message = ''): void |
||
1852 | |||
1853 | /** |
||
1854 | * Asserts that a variable is of type numeric. |
||
1855 | * |
||
1856 | * @throws ExpectationFailedException |
||
1857 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1858 | */ |
||
1859 | public static function assertIsNumeric($actual, string $message = ''): void |
||
1867 | |||
1868 | /** |
||
1869 | * Asserts that a variable is of type object. |
||
1870 | * |
||
1871 | * @throws ExpectationFailedException |
||
1872 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1873 | */ |
||
1874 | public static function assertIsObject($actual, string $message = ''): void |
||
1882 | |||
1883 | /** |
||
1884 | * Asserts that a variable is of type resource. |
||
1885 | * |
||
1886 | * @throws ExpectationFailedException |
||
1887 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1888 | */ |
||
1889 | public static function assertIsResource($actual, string $message = ''): void |
||
1897 | |||
1898 | /** |
||
1899 | * Asserts that a variable is of type string. |
||
1900 | * |
||
1901 | * @throws ExpectationFailedException |
||
1902 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1903 | */ |
||
1904 | public static function assertIsString($actual, string $message = ''): void |
||
1912 | |||
1913 | /** |
||
1914 | * Asserts that a variable is of type scalar. |
||
1915 | * |
||
1916 | * @throws ExpectationFailedException |
||
1917 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1918 | */ |
||
1919 | public static function assertIsScalar($actual, string $message = ''): void |
||
1927 | |||
1928 | /** |
||
1929 | * Asserts that a variable is of type callable. |
||
1930 | * |
||
1931 | * @throws ExpectationFailedException |
||
1932 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1933 | */ |
||
1934 | public static function assertIsCallable($actual, string $message = ''): void |
||
1942 | |||
1943 | /** |
||
1944 | * Asserts that a variable is of type iterable. |
||
1945 | * |
||
1946 | * @throws ExpectationFailedException |
||
1947 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1948 | */ |
||
1949 | public static function assertIsIterable($actual, string $message = ''): void |
||
1957 | |||
1958 | /** |
||
1959 | * Asserts that a variable is not of a given type. |
||
1960 | * |
||
1961 | * @throws ExpectationFailedException |
||
1962 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1963 | * |
||
1964 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3369 |
||
1965 | * @codeCoverageIgnore |
||
1966 | */ |
||
1967 | public static function assertNotInternalType(string $expected, $actual, string $message = ''): void |
||
1979 | |||
1980 | /** |
||
1981 | * Asserts that a variable is not of type array. |
||
1982 | * |
||
1983 | * @throws ExpectationFailedException |
||
1984 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
1985 | */ |
||
1986 | public static function assertIsNotArray($actual, string $message = ''): void |
||
1994 | |||
1995 | /** |
||
1996 | * Asserts that a variable is not of type bool. |
||
1997 | * |
||
1998 | * @throws ExpectationFailedException |
||
1999 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2000 | */ |
||
2001 | public static function assertIsNotBool($actual, string $message = ''): void |
||
2009 | |||
2010 | /** |
||
2011 | * Asserts that a variable is not of type float. |
||
2012 | * |
||
2013 | * @throws ExpectationFailedException |
||
2014 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2015 | */ |
||
2016 | public static function assertIsNotFloat($actual, string $message = ''): void |
||
2024 | |||
2025 | /** |
||
2026 | * Asserts that a variable is not of type int. |
||
2027 | * |
||
2028 | * @throws ExpectationFailedException |
||
2029 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2030 | */ |
||
2031 | public static function assertIsNotInt($actual, string $message = ''): void |
||
2039 | |||
2040 | /** |
||
2041 | * Asserts that a variable is not of type numeric. |
||
2042 | * |
||
2043 | * @throws ExpectationFailedException |
||
2044 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2045 | */ |
||
2046 | public static function assertIsNotNumeric($actual, string $message = ''): void |
||
2054 | |||
2055 | /** |
||
2056 | * Asserts that a variable is not of type object. |
||
2057 | * |
||
2058 | * @throws ExpectationFailedException |
||
2059 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2060 | */ |
||
2061 | public static function assertIsNotObject($actual, string $message = ''): void |
||
2069 | |||
2070 | /** |
||
2071 | * Asserts that a variable is not of type resource. |
||
2072 | * |
||
2073 | * @throws ExpectationFailedException |
||
2074 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2075 | */ |
||
2076 | public static function assertIsNotResource($actual, string $message = ''): void |
||
2084 | |||
2085 | /** |
||
2086 | * Asserts that a variable is not of type string. |
||
2087 | * |
||
2088 | * @throws ExpectationFailedException |
||
2089 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2090 | */ |
||
2091 | public static function assertIsNotString($actual, string $message = ''): void |
||
2099 | |||
2100 | /** |
||
2101 | * Asserts that a variable is not of type scalar. |
||
2102 | * |
||
2103 | * @throws ExpectationFailedException |
||
2104 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2105 | */ |
||
2106 | public static function assertIsNotScalar($actual, string $message = ''): void |
||
2114 | |||
2115 | /** |
||
2116 | * Asserts that a variable is not of type callable. |
||
2117 | * |
||
2118 | * @throws ExpectationFailedException |
||
2119 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2120 | */ |
||
2121 | public static function assertIsNotCallable($actual, string $message = ''): void |
||
2129 | |||
2130 | /** |
||
2131 | * Asserts that a variable is not of type iterable. |
||
2132 | * |
||
2133 | * @throws ExpectationFailedException |
||
2134 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2135 | */ |
||
2136 | public static function assertIsNotIterable($actual, string $message = ''): void |
||
2144 | |||
2145 | /** |
||
2146 | * Asserts that an attribute is of a given type. |
||
2147 | * |
||
2148 | * @param object|string $classOrObject |
||
2149 | * |
||
2150 | * @throws ExpectationFailedException |
||
2151 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2152 | * @throws ReflectionException |
||
2153 | * @throws Exception |
||
2154 | * |
||
2155 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
2156 | * @codeCoverageIgnore |
||
2157 | */ |
||
2158 | public static function assertAttributeNotInternalType(string $expected, string $attributeName, $classOrObject, string $message = ''): void |
||
2168 | |||
2169 | /** |
||
2170 | * Asserts that a string matches a given regular expression. |
||
2171 | * |
||
2172 | * @throws ExpectationFailedException |
||
2173 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2174 | */ |
||
2175 | public static function assertRegExp(string $pattern, string $string, string $message = ''): void |
||
2179 | |||
2180 | /** |
||
2181 | * Asserts that a string does not match a given regular expression. |
||
2182 | * |
||
2183 | * @throws ExpectationFailedException |
||
2184 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2185 | */ |
||
2186 | public static function assertNotRegExp(string $pattern, string $string, string $message = ''): void |
||
2196 | |||
2197 | /** |
||
2198 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) |
||
2199 | * is the same. |
||
2200 | * |
||
2201 | * @param Countable|iterable $expected |
||
2202 | * @param Countable|iterable $actual |
||
2203 | * |
||
2204 | * @throws ExpectationFailedException |
||
2205 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2206 | * @throws Exception |
||
2207 | */ |
||
2208 | public static function assertSameSize($expected, $actual, string $message = ''): void |
||
2224 | |||
2225 | /** |
||
2226 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) |
||
2227 | * is not the same. |
||
2228 | * |
||
2229 | * @param Countable|iterable $expected |
||
2230 | * @param Countable|iterable $actual |
||
2231 | * |
||
2232 | * @throws ExpectationFailedException |
||
2233 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2234 | * @throws Exception |
||
2235 | */ |
||
2236 | public static function assertNotSameSize($expected, $actual, string $message = ''): void |
||
2254 | |||
2255 | /** |
||
2256 | * Asserts that a string matches a given format string. |
||
2257 | * |
||
2258 | * @throws ExpectationFailedException |
||
2259 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2260 | */ |
||
2261 | public static function assertStringMatchesFormat(string $format, string $string, string $message = ''): void |
||
2265 | |||
2266 | /** |
||
2267 | * Asserts that a string does not match a given format string. |
||
2268 | * |
||
2269 | * @throws ExpectationFailedException |
||
2270 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2271 | */ |
||
2272 | public static function assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void |
||
2282 | |||
2283 | /** |
||
2284 | * Asserts that a string matches a given format file. |
||
2285 | * |
||
2286 | * @throws ExpectationFailedException |
||
2287 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2288 | */ |
||
2289 | public static function assertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void |
||
2301 | |||
2302 | /** |
||
2303 | * Asserts that a string does not match a given format string. |
||
2304 | * |
||
2305 | * @throws ExpectationFailedException |
||
2306 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2307 | */ |
||
2308 | public static function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void |
||
2322 | |||
2323 | /** |
||
2324 | * Asserts that a string starts with a given prefix. |
||
2325 | * |
||
2326 | * @throws ExpectationFailedException |
||
2327 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2328 | */ |
||
2329 | public static function assertStringStartsWith(string $prefix, string $string, string $message = ''): void |
||
2333 | |||
2334 | /** |
||
2335 | * Asserts that a string starts not with a given prefix. |
||
2336 | * |
||
2337 | * @param string $prefix |
||
2338 | * @param string $string |
||
2339 | * |
||
2340 | * @throws ExpectationFailedException |
||
2341 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2342 | */ |
||
2343 | public static function assertStringStartsNotWith($prefix, $string, string $message = ''): void |
||
2353 | |||
2354 | /** |
||
2355 | * @throws ExpectationFailedException |
||
2356 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2357 | */ |
||
2358 | public static function assertStringContainsString(string $needle, string $haystack, string $message = ''): void |
||
2364 | |||
2365 | /** |
||
2366 | * @throws ExpectationFailedException |
||
2367 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2368 | */ |
||
2369 | public static function assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void |
||
2375 | |||
2376 | /** |
||
2377 | * @throws ExpectationFailedException |
||
2378 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2379 | */ |
||
2380 | public static function assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void |
||
2386 | |||
2387 | /** |
||
2388 | * @throws ExpectationFailedException |
||
2389 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2390 | */ |
||
2391 | public static function assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void |
||
2397 | |||
2398 | /** |
||
2399 | * Asserts that a string ends with a given suffix. |
||
2400 | * |
||
2401 | * @throws ExpectationFailedException |
||
2402 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2403 | */ |
||
2404 | public static function assertStringEndsWith(string $suffix, string $string, string $message = ''): void |
||
2408 | |||
2409 | /** |
||
2410 | * Asserts that a string ends not with a given suffix. |
||
2411 | * |
||
2412 | * @throws ExpectationFailedException |
||
2413 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2414 | */ |
||
2415 | public static function assertStringEndsNotWith(string $suffix, string $string, string $message = ''): void |
||
2425 | |||
2426 | /** |
||
2427 | * Asserts that two XML files are equal. |
||
2428 | * |
||
2429 | * @throws ExpectationFailedException |
||
2430 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2431 | * @throws Exception |
||
2432 | */ |
||
2433 | public static function assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void |
||
2440 | |||
2441 | /** |
||
2442 | * Asserts that two XML files are not equal. |
||
2443 | * |
||
2444 | * @throws ExpectationFailedException |
||
2445 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2446 | * @throws Exception |
||
2447 | */ |
||
2448 | public static function assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void |
||
2455 | |||
2456 | /** |
||
2457 | * Asserts that two XML documents are equal. |
||
2458 | * |
||
2459 | * @param DOMDocument|string $actualXml |
||
2460 | * |
||
2461 | * @throws ExpectationFailedException |
||
2462 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2463 | * @throws Exception |
||
2464 | */ |
||
2465 | public static function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void |
||
2472 | |||
2473 | /** |
||
2474 | * Asserts that two XML documents are not equal. |
||
2475 | * |
||
2476 | * @param DOMDocument|string $actualXml |
||
2477 | * |
||
2478 | * @throws ExpectationFailedException |
||
2479 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2480 | * @throws Exception |
||
2481 | */ |
||
2482 | public static function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void |
||
2489 | |||
2490 | /** |
||
2491 | * Asserts that two XML documents are equal. |
||
2492 | * |
||
2493 | * @param DOMDocument|string $expectedXml |
||
2494 | * @param DOMDocument|string $actualXml |
||
2495 | * |
||
2496 | * @throws ExpectationFailedException |
||
2497 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2498 | * @throws Exception |
||
2499 | */ |
||
2500 | public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $message = ''): void |
||
2507 | |||
2508 | /** |
||
2509 | * Asserts that two XML documents are not equal. |
||
2510 | * |
||
2511 | * @param DOMDocument|string $expectedXml |
||
2512 | * @param DOMDocument|string $actualXml |
||
2513 | * |
||
2514 | * @throws ExpectationFailedException |
||
2515 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2516 | * @throws Exception |
||
2517 | */ |
||
2518 | public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, string $message = ''): void |
||
2525 | |||
2526 | /** |
||
2527 | * Asserts that a hierarchy of DOMElements matches. |
||
2528 | * |
||
2529 | * @throws AssertionFailedError |
||
2530 | * @throws ExpectationFailedException |
||
2531 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2532 | */ |
||
2533 | public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void |
||
2599 | |||
2600 | /** |
||
2601 | * Evaluates a PHPUnit\Framework\Constraint matcher object. |
||
2602 | * |
||
2603 | * @throws ExpectationFailedException |
||
2604 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2605 | */ |
||
2606 | public static function assertThat($value, Constraint $constraint, string $message = ''): void |
||
2612 | |||
2613 | /** |
||
2614 | * Asserts that a string is a valid JSON string. |
||
2615 | * |
||
2616 | * @throws ExpectationFailedException |
||
2617 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2618 | */ |
||
2619 | public static function assertJson(string $actualJson, string $message = ''): void |
||
2623 | |||
2624 | /** |
||
2625 | * Asserts that two given JSON encoded objects or arrays are equal. |
||
2626 | * |
||
2627 | * @throws ExpectationFailedException |
||
2628 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2629 | */ |
||
2630 | public static function assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void |
||
2637 | |||
2638 | /** |
||
2639 | * Asserts that two given JSON encoded objects or arrays are not equal. |
||
2640 | * |
||
2641 | * @param string $expectedJson |
||
2642 | * @param string $actualJson |
||
2643 | * |
||
2644 | * @throws ExpectationFailedException |
||
2645 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2646 | */ |
||
2647 | public static function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, string $message = ''): void |
||
2660 | |||
2661 | /** |
||
2662 | * Asserts that the generated JSON encoded object and the content of the given file are equal. |
||
2663 | * |
||
2664 | * @throws ExpectationFailedException |
||
2665 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2666 | */ |
||
2667 | public static function assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void |
||
2677 | |||
2678 | /** |
||
2679 | * Asserts that the generated JSON encoded object and the content of the given file are not equal. |
||
2680 | * |
||
2681 | * @throws ExpectationFailedException |
||
2682 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2683 | */ |
||
2684 | public static function assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void |
||
2700 | |||
2701 | /** |
||
2702 | * Asserts that two JSON files are equal. |
||
2703 | * |
||
2704 | * @throws ExpectationFailedException |
||
2705 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2706 | */ |
||
2707 | public static function assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void |
||
2727 | |||
2728 | /** |
||
2729 | * Asserts that two JSON files are not equal. |
||
2730 | * |
||
2731 | * @throws ExpectationFailedException |
||
2732 | * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException |
||
2733 | */ |
||
2734 | public static function assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void |
||
2754 | |||
2755 | /** |
||
2756 | * @throws Exception |
||
2757 | */ |
||
2758 | public static function logicalAnd(): LogicalAnd |
||
2767 | |||
2768 | public static function logicalOr(): LogicalOr |
||
2777 | |||
2778 | public static function logicalNot(Constraint $constraint): LogicalNot |
||
2782 | |||
2783 | public static function logicalXor(): LogicalXor |
||
2792 | |||
2793 | public static function anything(): IsAnything |
||
2797 | |||
2798 | public static function isTrue(): IsTrue |
||
2802 | |||
2803 | public static function callback(callable $callback): Callback |
||
2807 | |||
2808 | public static function isFalse(): IsFalse |
||
2812 | |||
2813 | public static function isJson(): IsJson |
||
2817 | |||
2818 | public static function isNull(): IsNull |
||
2822 | |||
2823 | public static function isFinite(): IsFinite |
||
2827 | |||
2828 | public static function isInfinite(): IsInfinite |
||
2832 | |||
2833 | public static function isNan(): IsNan |
||
2837 | |||
2838 | /** |
||
2839 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
2840 | * @codeCoverageIgnore |
||
2841 | */ |
||
2842 | public static function attribute(Constraint $constraint, string $attributeName): Attribute |
||
2848 | |||
2849 | public static function contains($value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): TraversableContains |
||
2853 | |||
2854 | public static function containsOnly(string $type): TraversableContainsOnly |
||
2858 | |||
2859 | public static function containsOnlyInstancesOf(string $className): TraversableContainsOnly |
||
2863 | |||
2864 | /** |
||
2865 | * @param int|string $key |
||
2866 | */ |
||
2867 | public static function arrayHasKey($key): ArrayHasKey |
||
2871 | |||
2872 | public static function equalTo($value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): IsEqual |
||
2876 | |||
2877 | /** |
||
2878 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
2879 | * @codeCoverageIgnore |
||
2880 | */ |
||
2881 | public static function attributeEqualTo(string $attributeName, $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): Attribute |
||
2896 | |||
2897 | public static function isEmpty(): IsEmpty |
||
2901 | |||
2902 | public static function isWritable(): IsWritable |
||
2906 | |||
2907 | public static function isReadable(): IsReadable |
||
2911 | |||
2912 | public static function directoryExists(): DirectoryExists |
||
2916 | |||
2917 | public static function fileExists(): FileExists |
||
2921 | |||
2922 | public static function greaterThan($value): GreaterThan |
||
2926 | |||
2927 | public static function greaterThanOrEqual($value): LogicalOr |
||
2934 | |||
2935 | public static function classHasAttribute(string $attributeName): ClassHasAttribute |
||
2939 | |||
2940 | public static function classHasStaticAttribute(string $attributeName): ClassHasStaticAttribute |
||
2944 | |||
2945 | public static function objectHasAttribute($attributeName): ObjectHasAttribute |
||
2949 | |||
2950 | public static function identicalTo($value): IsIdentical |
||
2954 | |||
2955 | public static function isInstanceOf(string $className): IsInstanceOf |
||
2959 | |||
2960 | public static function isType(string $type): IsType |
||
2964 | |||
2965 | public static function lessThan($value): LessThan |
||
2969 | |||
2970 | public static function lessThanOrEqual($value): LogicalOr |
||
2977 | |||
2978 | public static function matchesRegularExpression(string $pattern): RegularExpression |
||
2982 | |||
2983 | public static function matches(string $string): StringMatchesFormatDescription |
||
2987 | |||
2988 | public static function stringStartsWith($prefix): StringStartsWith |
||
2992 | |||
2993 | public static function stringContains(string $string, bool $case = true): StringContains |
||
2997 | |||
2998 | public static function stringEndsWith(string $suffix): StringEndsWith |
||
3002 | |||
3003 | public static function countOf(int $count): Count |
||
3007 | |||
3008 | /** |
||
3009 | * Fails a test with the given message. |
||
3010 | * |
||
3011 | * @throws AssertionFailedError |
||
3012 | */ |
||
3013 | public static function fail(string $message = ''): void |
||
3019 | |||
3020 | /** |
||
3021 | * Returns the value of an attribute of a class or an object. |
||
3022 | * This also works for attributes that are declared protected or private. |
||
3023 | * |
||
3024 | * @param object|string $classOrObject |
||
3025 | * |
||
3026 | * @throws Exception |
||
3027 | * @throws ReflectionException |
||
3028 | * |
||
3029 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
3030 | * @codeCoverageIgnore |
||
3031 | */ |
||
3032 | public static function readAttribute($classOrObject, string $attributeName) |
||
3066 | |||
3067 | /** |
||
3068 | * Returns the value of a static attribute. |
||
3069 | * This also works for attributes that are declared protected or private. |
||
3070 | * |
||
3071 | * @throws Exception |
||
3072 | * @throws ReflectionException |
||
3073 | * |
||
3074 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
3075 | * @codeCoverageIgnore |
||
3076 | */ |
||
3077 | public static function getStaticAttribute(string $className, string $attributeName) |
||
3108 | |||
3109 | /** |
||
3110 | * Returns the value of an object's attribute. |
||
3111 | * This also works for attributes that are declared protected or private. |
||
3112 | * |
||
3113 | * @param object $object |
||
3114 | * |
||
3115 | * @throws Exception |
||
3116 | * |
||
3117 | * @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338 |
||
3118 | * @codeCoverageIgnore |
||
3119 | */ |
||
3120 | public static function getObjectAttribute($object, string $attributeName) |
||
3161 | |||
3162 | /** |
||
3163 | * Mark the test as incomplete. |
||
3164 | * |
||
3165 | * @throws IncompleteTestError |
||
3166 | */ |
||
3167 | public static function markTestIncomplete(string $message = ''): void |
||
3171 | |||
3172 | /** |
||
3173 | * Mark the test as skipped. |
||
3174 | * |
||
3175 | * @throws SkippedTestError |
||
3176 | * @throws SyntheticSkippedError |
||
3177 | */ |
||
3178 | public static function markTestSkipped(string $message = ''): void |
||
3189 | |||
3190 | /** |
||
3191 | * Return the current assertion count. |
||
3192 | */ |
||
3193 | public static function getCount(): int |
||
3197 | |||
3198 | /** |
||
3199 | * Reset the assertion counter. |
||
3200 | */ |
||
3201 | public static function resetCount(): void |
||
3205 | |||
3206 | private static function detectLocationHint(string $message): ?array |
||
3229 | |||
3230 | private static function isValidObjectAttributeName(string $attributeName): bool |
||
3234 | |||
3235 | private static function isValidClassAttributeName(string $attributeName): bool |
||
3239 | |||
3240 | /** |
||
3241 | * @codeCoverageIgnore |
||
3242 | */ |
||
3243 | private static function createWarning(string $warning): void |
||
3255 | } |
||
3256 |