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 |
||
| 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 mixed $key |
||
| 81 | * @param array|ArrayAccess $array |
||
| 82 | * @param string $message |
||
| 83 | */ |
||
| 84 | public static function assertArrayHasKey($key, $array, $message = '') |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Asserts that an array has a specified subset. |
||
| 107 | * |
||
| 108 | * @param array|ArrayAccess $subset |
||
| 109 | * @param array|ArrayAccess $array |
||
| 110 | * @param bool $strict Check for object identity |
||
| 111 | * @param string $message |
||
| 112 | */ |
||
| 113 | public static function assertArraySubset($subset, $array, $strict = false, $message = '') |
||
| 133 | |||
| 134 | /** |
||
| 135 | * Asserts that an array does not have a specified key. |
||
| 136 | * |
||
| 137 | * @param mixed $key |
||
| 138 | * @param array|ArrayAccess $array |
||
| 139 | * @param string $message |
||
| 140 | */ |
||
| 141 | public static function assertArrayNotHasKey($key, $array, $message = '') |
||
| 163 | |||
| 164 | /** |
||
| 165 | * Asserts that a haystack contains a needle. |
||
| 166 | * |
||
| 167 | * @param mixed $needle |
||
| 168 | * @param mixed $haystack |
||
| 169 | * @param string $message |
||
| 170 | * @param bool $ignoreCase |
||
| 171 | * @param bool $checkForObjectIdentity |
||
| 172 | * @param bool $checkForNonObjectIdentity |
||
| 173 | */ |
||
| 174 | public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Asserts that a haystack that is stored in a static attribute of a class |
||
| 207 | * or an attribute of an object contains a needle. |
||
| 208 | * |
||
| 209 | * @param mixed $needle |
||
| 210 | * @param string $haystackAttributeName |
||
| 211 | * @param string|object $haystackClassOrObject |
||
| 212 | * @param string $message |
||
| 213 | * @param bool $ignoreCase |
||
| 214 | * @param bool $checkForObjectIdentity |
||
| 215 | * @param bool $checkForNonObjectIdentity |
||
| 216 | */ |
||
| 217 | public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Asserts that a haystack does not contain a needle. |
||
| 231 | * |
||
| 232 | * @param mixed $needle |
||
| 233 | * @param mixed $haystack |
||
| 234 | * @param string $message |
||
| 235 | * @param bool $ignoreCase |
||
| 236 | * @param bool $checkForObjectIdentity |
||
| 237 | * @param bool $checkForNonObjectIdentity |
||
| 238 | */ |
||
| 239 | public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
||
| 273 | |||
| 274 | /** |
||
| 275 | * Asserts that a haystack that is stored in a static attribute of a class |
||
| 276 | * or an attribute of an object does not contain a needle. |
||
| 277 | * |
||
| 278 | * @param mixed $needle |
||
| 279 | * @param string $haystackAttributeName |
||
| 280 | * @param string|object $haystackClassOrObject |
||
| 281 | * @param string $message |
||
| 282 | * @param bool $ignoreCase |
||
| 283 | * @param bool $checkForObjectIdentity |
||
| 284 | * @param bool $checkForNonObjectIdentity |
||
| 285 | */ |
||
| 286 | public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Asserts that a haystack contains only values of a given type. |
||
| 300 | * |
||
| 301 | * @param string $type |
||
| 302 | * @param mixed $haystack |
||
| 303 | * @param bool $isNativeType |
||
| 304 | * @param string $message |
||
| 305 | */ |
||
| 306 | public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Asserts that a haystack contains only instances of a given classname |
||
| 332 | * |
||
| 333 | * @param string $classname |
||
| 334 | * @param array|Traversable $haystack |
||
| 335 | * @param string $message |
||
| 336 | */ |
||
| 337 | public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '') |
||
| 356 | |||
| 357 | /** |
||
| 358 | * Asserts that a haystack that is stored in a static attribute of a class |
||
| 359 | * or an attribute of an object contains only values of a given type. |
||
| 360 | * |
||
| 361 | * @param string $type |
||
| 362 | * @param string $haystackAttributeName |
||
| 363 | * @param string|object $haystackClassOrObject |
||
| 364 | * @param bool $isNativeType |
||
| 365 | * @param string $message |
||
| 366 | */ |
||
| 367 | public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '') |
||
| 376 | |||
| 377 | /** |
||
| 378 | * Asserts that a haystack does not contain only values of a given type. |
||
| 379 | * |
||
| 380 | * @param string $type |
||
| 381 | * @param mixed $haystack |
||
| 382 | * @param bool $isNativeType |
||
| 383 | * @param string $message |
||
| 384 | */ |
||
| 385 | public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
||
| 410 | |||
| 411 | /** |
||
| 412 | * Asserts that a haystack that is stored in a static attribute of a class |
||
| 413 | * or an attribute of an object does not contain only values of a given |
||
| 414 | * type. |
||
| 415 | * |
||
| 416 | * @param string $type |
||
| 417 | * @param string $haystackAttributeName |
||
| 418 | * @param string|object $haystackClassOrObject |
||
| 419 | * @param bool $isNativeType |
||
| 420 | * @param string $message |
||
| 421 | */ |
||
| 422 | public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '') |
||
| 431 | |||
| 432 | /** |
||
| 433 | * Asserts the number of elements of an array, Countable or Traversable. |
||
| 434 | * |
||
| 435 | * @param int $expectedCount |
||
| 436 | * @param mixed $haystack |
||
| 437 | * @param string $message |
||
| 438 | */ |
||
| 439 | public static function assertCount($expectedCount, $haystack, $message = '') |
||
| 457 | |||
| 458 | /** |
||
| 459 | * Asserts the number of elements of an array, Countable or Traversable |
||
| 460 | * that is stored in an attribute. |
||
| 461 | * |
||
| 462 | * @param int $expectedCount |
||
| 463 | * @param string $haystackAttributeName |
||
| 464 | * @param string|object $haystackClassOrObject |
||
| 465 | * @param string $message |
||
| 466 | */ |
||
| 467 | public static function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') |
||
| 475 | |||
| 476 | /** |
||
| 477 | * Asserts the number of elements of an array, Countable or Traversable. |
||
| 478 | * |
||
| 479 | * @param int $expectedCount |
||
| 480 | * @param mixed $haystack |
||
| 481 | * @param string $message |
||
| 482 | */ |
||
| 483 | public static function assertNotCount($expectedCount, $haystack, $message = '') |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Asserts the number of elements of an array, Countable or Traversable |
||
| 504 | * that is stored in an attribute. |
||
| 505 | * |
||
| 506 | * @param int $expectedCount |
||
| 507 | * @param string $haystackAttributeName |
||
| 508 | * @param string|object $haystackClassOrObject |
||
| 509 | * @param string $message |
||
| 510 | */ |
||
| 511 | public static function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') |
||
| 519 | |||
| 520 | /** |
||
| 521 | * Asserts that two variables are equal. |
||
| 522 | * |
||
| 523 | * @param mixed $expected |
||
| 524 | * @param mixed $actual |
||
| 525 | * @param string $message |
||
| 526 | * @param float $delta |
||
| 527 | * @param int $maxDepth |
||
| 528 | * @param bool $canonicalize |
||
| 529 | * @param bool $ignoreCase |
||
| 530 | */ |
||
| 531 | public static function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
| 543 | |||
| 544 | /** |
||
| 545 | * Asserts that a variable is equal to an attribute of an object. |
||
| 546 | * |
||
| 547 | * @param mixed $expected |
||
| 548 | * @param string $actualAttributeName |
||
| 549 | * @param string|object $actualClassOrObject |
||
| 550 | * @param string $message |
||
| 551 | * @param float $delta |
||
| 552 | * @param int $maxDepth |
||
| 553 | * @param bool $canonicalize |
||
| 554 | * @param bool $ignoreCase |
||
| 555 | */ |
||
| 556 | public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
| 568 | |||
| 569 | /** |
||
| 570 | * Asserts that two variables are not equal. |
||
| 571 | * |
||
| 572 | * @param mixed $expected |
||
| 573 | * @param mixed $actual |
||
| 574 | * @param string $message |
||
| 575 | * @param float $delta |
||
| 576 | * @param int $maxDepth |
||
| 577 | * @param bool $canonicalize |
||
| 578 | * @param bool $ignoreCase |
||
| 579 | */ |
||
| 580 | public static function assertNotEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
| 594 | |||
| 595 | /** |
||
| 596 | * Asserts that a variable is not equal to an attribute of an object. |
||
| 597 | * |
||
| 598 | * @param mixed $expected |
||
| 599 | * @param string $actualAttributeName |
||
| 600 | * @param string|object $actualClassOrObject |
||
| 601 | * @param string $message |
||
| 602 | * @param float $delta |
||
| 603 | * @param int $maxDepth |
||
| 604 | * @param bool $canonicalize |
||
| 605 | * @param bool $ignoreCase |
||
| 606 | */ |
||
| 607 | public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Asserts that a variable is empty. |
||
| 622 | * |
||
| 623 | * @param mixed $actual |
||
| 624 | * @param string $message |
||
| 625 | * |
||
| 626 | * @throws AssertionFailedError |
||
| 627 | */ |
||
| 628 | public static function assertEmpty($actual, $message = '') |
||
| 632 | |||
| 633 | /** |
||
| 634 | * Asserts that a static attribute of a class or an attribute of an object |
||
| 635 | * is empty. |
||
| 636 | * |
||
| 637 | * @param string $haystackAttributeName |
||
| 638 | * @param string|object $haystackClassOrObject |
||
| 639 | * @param string $message |
||
| 640 | */ |
||
| 641 | public static function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Asserts that a variable is not empty. |
||
| 651 | * |
||
| 652 | * @param mixed $actual |
||
| 653 | * @param string $message |
||
| 654 | * |
||
| 655 | * @throws AssertionFailedError |
||
| 656 | */ |
||
| 657 | public static function assertNotEmpty($actual, $message = '') |
||
| 661 | |||
| 662 | /** |
||
| 663 | * Asserts that a static attribute of a class or an attribute of an object |
||
| 664 | * is not empty. |
||
| 665 | * |
||
| 666 | * @param string $haystackAttributeName |
||
| 667 | * @param string|object $haystackClassOrObject |
||
| 668 | * @param string $message |
||
| 669 | */ |
||
| 670 | public static function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') |
||
| 677 | |||
| 678 | /** |
||
| 679 | * Asserts that a value is greater than another value. |
||
| 680 | * |
||
| 681 | * @param mixed $expected |
||
| 682 | * @param mixed $actual |
||
| 683 | * @param string $message |
||
| 684 | */ |
||
| 685 | public static function assertGreaterThan($expected, $actual, $message = '') |
||
| 689 | |||
| 690 | /** |
||
| 691 | * Asserts that an attribute is greater than another value. |
||
| 692 | * |
||
| 693 | * @param mixed $expected |
||
| 694 | * @param string $actualAttributeName |
||
| 695 | * @param string|object $actualClassOrObject |
||
| 696 | * @param string $message |
||
| 697 | */ |
||
| 698 | public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
| 706 | |||
| 707 | /** |
||
| 708 | * Asserts that a value is greater than or equal to another value. |
||
| 709 | * |
||
| 710 | * @param mixed $expected |
||
| 711 | * @param mixed $actual |
||
| 712 | * @param string $message |
||
| 713 | */ |
||
| 714 | public static function assertGreaterThanOrEqual($expected, $actual, $message = '') |
||
| 722 | |||
| 723 | /** |
||
| 724 | * Asserts that an attribute is greater than or equal to another value. |
||
| 725 | * |
||
| 726 | * @param mixed $expected |
||
| 727 | * @param string $actualAttributeName |
||
| 728 | * @param string|object $actualClassOrObject |
||
| 729 | * @param string $message |
||
| 730 | */ |
||
| 731 | public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
| 739 | |||
| 740 | /** |
||
| 741 | * Asserts that a value is smaller than another value. |
||
| 742 | * |
||
| 743 | * @param mixed $expected |
||
| 744 | * @param mixed $actual |
||
| 745 | * @param string $message |
||
| 746 | */ |
||
| 747 | public static function assertLessThan($expected, $actual, $message = '') |
||
| 751 | |||
| 752 | /** |
||
| 753 | * Asserts that an attribute is smaller than another value. |
||
| 754 | * |
||
| 755 | * @param mixed $expected |
||
| 756 | * @param string $actualAttributeName |
||
| 757 | * @param string|object $actualClassOrObject |
||
| 758 | * @param string $message |
||
| 759 | */ |
||
| 760 | public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
| 768 | |||
| 769 | /** |
||
| 770 | * Asserts that a value is smaller than or equal to another value. |
||
| 771 | * |
||
| 772 | * @param mixed $expected |
||
| 773 | * @param mixed $actual |
||
| 774 | * @param string $message |
||
| 775 | */ |
||
| 776 | public static function assertLessThanOrEqual($expected, $actual, $message = '') |
||
| 780 | |||
| 781 | /** |
||
| 782 | * Asserts that an attribute is smaller than or equal to another value. |
||
| 783 | * |
||
| 784 | * @param mixed $expected |
||
| 785 | * @param string $actualAttributeName |
||
| 786 | * @param string|object $actualClassOrObject |
||
| 787 | * @param string $message |
||
| 788 | */ |
||
| 789 | public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
| 797 | |||
| 798 | /** |
||
| 799 | * Asserts that the contents of one file is equal to the contents of another |
||
| 800 | * file. |
||
| 801 | * |
||
| 802 | * @param string $expected |
||
| 803 | * @param string $actual |
||
| 804 | * @param string $message |
||
| 805 | * @param bool $canonicalize |
||
| 806 | * @param bool $ignoreCase |
||
| 807 | */ |
||
| 808 | public static function assertFileEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false) |
||
| 823 | |||
| 824 | /** |
||
| 825 | * Asserts that the contents of one file is not equal to the contents of |
||
| 826 | * another file. |
||
| 827 | * |
||
| 828 | * @param string $expected |
||
| 829 | * @param string $actual |
||
| 830 | * @param string $message |
||
| 831 | * @param bool $canonicalize |
||
| 832 | * @param bool $ignoreCase |
||
| 833 | */ |
||
| 834 | public static function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false) |
||
| 849 | |||
| 850 | /** |
||
| 851 | * Asserts that the contents of a string is equal |
||
| 852 | * to the contents of a file. |
||
| 853 | * |
||
| 854 | * @param string $expectedFile |
||
| 855 | * @param string $actualString |
||
| 856 | * @param string $message |
||
| 857 | * @param bool $canonicalize |
||
| 858 | * @param bool $ignoreCase |
||
| 859 | */ |
||
| 860 | 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 | public static function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false) |
||
| 899 | |||
| 900 | /** |
||
| 901 | * Asserts that a file/dir is readable. |
||
| 902 | * |
||
| 903 | * @param string $filename |
||
| 904 | * @param string $message |
||
| 905 | */ |
||
| 906 | public static function assertIsReadable($filename, $message = '') |
||
| 916 | |||
| 917 | /** |
||
| 918 | * Asserts that a file/dir exists and is not readable. |
||
| 919 | * |
||
| 920 | * @param string $filename |
||
| 921 | * @param string $message |
||
| 922 | */ |
||
| 923 | public static function assertNotIsReadable($filename, $message = '') |
||
| 935 | |||
| 936 | /** |
||
| 937 | * Asserts that a file/dir exists and is writable. |
||
| 938 | * |
||
| 939 | * @param string $filename |
||
| 940 | * @param string $message |
||
| 941 | */ |
||
| 942 | public static function assertIsWritable($filename, $message = '') |
||
| 952 | |||
| 953 | /** |
||
| 954 | * Asserts that a file/dir exists and is not writable. |
||
| 955 | * |
||
| 956 | * @param string $filename |
||
| 957 | * @param string $message |
||
| 958 | */ |
||
| 959 | public static function assertNotIsWritable($filename, $message = '') |
||
| 971 | |||
| 972 | /** |
||
| 973 | * Asserts that a directory exists. |
||
| 974 | * |
||
| 975 | * @param string $directory |
||
| 976 | * @param string $message |
||
| 977 | */ |
||
| 978 | public static function assertDirectoryExists($directory, $message = '') |
||
| 988 | |||
| 989 | /** |
||
| 990 | * Asserts that a directory does not exist. |
||
| 991 | * |
||
| 992 | * @param string $directory |
||
| 993 | * @param string $message |
||
| 994 | */ |
||
| 995 | public static function assertDirectoryNotExists($directory, $message = '') |
||
| 1007 | |||
| 1008 | /** |
||
| 1009 | * Asserts that a directory exists and is readable. |
||
| 1010 | * |
||
| 1011 | * @param string $directory |
||
| 1012 | * @param string $message |
||
| 1013 | */ |
||
| 1014 | public static function assertDirectoryIsReadable($directory, $message = '') |
||
| 1019 | |||
| 1020 | /** |
||
| 1021 | * Asserts that a directory exists and is not readable. |
||
| 1022 | * |
||
| 1023 | * @param string $directory |
||
| 1024 | * @param string $message |
||
| 1025 | */ |
||
| 1026 | public static function assertDirectoryNotIsReadable($directory, $message = '') |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Asserts that a directory exists and is writable. |
||
| 1034 | * |
||
| 1035 | * @param string $directory |
||
| 1036 | * @param string $message |
||
| 1037 | */ |
||
| 1038 | public static function assertDirectoryIsWritable($directory, $message = '') |
||
| 1043 | |||
| 1044 | /** |
||
| 1045 | * Asserts that a directory exists and is not writable. |
||
| 1046 | * |
||
| 1047 | * @param string $directory |
||
| 1048 | * @param string $message |
||
| 1049 | */ |
||
| 1050 | public static function assertDirectoryNotIsWritable($directory, $message = '') |
||
| 1055 | |||
| 1056 | /** |
||
| 1057 | * Asserts that a file exists. |
||
| 1058 | * |
||
| 1059 | * @param string $filename |
||
| 1060 | * @param string $message |
||
| 1061 | */ |
||
| 1062 | public static function assertFileExists($filename, $message = '') |
||
| 1072 | |||
| 1073 | /** |
||
| 1074 | * Asserts that a file does not exist. |
||
| 1075 | * |
||
| 1076 | * @param string $filename |
||
| 1077 | * @param string $message |
||
| 1078 | */ |
||
| 1079 | public static function assertFileNotExists($filename, $message = '') |
||
| 1091 | |||
| 1092 | /** |
||
| 1093 | * Asserts that a file exists and is readable. |
||
| 1094 | * |
||
| 1095 | * @param string $file |
||
| 1096 | * @param string $message |
||
| 1097 | */ |
||
| 1098 | public static function assertFileIsReadable($file, $message = '') |
||
| 1103 | |||
| 1104 | /** |
||
| 1105 | * Asserts that a file exists and is not readable. |
||
| 1106 | * |
||
| 1107 | * @param string $file |
||
| 1108 | * @param string $message |
||
| 1109 | */ |
||
| 1110 | public static function assertFileNotIsReadable($file, $message = '') |
||
| 1115 | |||
| 1116 | /** |
||
| 1117 | * Asserts that a file exists and is writable. |
||
| 1118 | * |
||
| 1119 | * @param string $file |
||
| 1120 | * @param string $message |
||
| 1121 | */ |
||
| 1122 | public static function assertFileIsWritable($file, $message = '') |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Asserts that a file exists and is not writable. |
||
| 1130 | * |
||
| 1131 | * @param string $file |
||
| 1132 | * @param string $message |
||
| 1133 | */ |
||
| 1134 | public static function assertFileNotIsWritable($file, $message = '') |
||
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Asserts that a condition is true. |
||
| 1142 | * |
||
| 1143 | * @param bool $condition |
||
| 1144 | * @param string $message |
||
| 1145 | * |
||
| 1146 | * @throws AssertionFailedError |
||
| 1147 | */ |
||
| 1148 | public static function assertTrue($condition, $message = '') |
||
| 1152 | |||
| 1153 | /** |
||
| 1154 | * Asserts that a condition is not true. |
||
| 1155 | * |
||
| 1156 | * @param bool $condition |
||
| 1157 | * @param string $message |
||
| 1158 | * |
||
| 1159 | * @throws AssertionFailedError |
||
| 1160 | */ |
||
| 1161 | public static function assertNotTrue($condition, $message = '') |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Asserts that a condition is false. |
||
| 1168 | * |
||
| 1169 | * @param bool $condition |
||
| 1170 | * @param string $message |
||
| 1171 | * |
||
| 1172 | * @throws AssertionFailedError |
||
| 1173 | */ |
||
| 1174 | public static function assertFalse($condition, $message = '') |
||
| 1178 | |||
| 1179 | /** |
||
| 1180 | * Asserts that a condition is not false. |
||
| 1181 | * |
||
| 1182 | * @param bool $condition |
||
| 1183 | * @param string $message |
||
| 1184 | * |
||
| 1185 | * @throws AssertionFailedError |
||
| 1186 | */ |
||
| 1187 | public static function assertNotFalse($condition, $message = '') |
||
| 1191 | |||
| 1192 | /** |
||
| 1193 | * Asserts that a variable is null. |
||
| 1194 | * |
||
| 1195 | * @param mixed $actual |
||
| 1196 | * @param string $message |
||
| 1197 | */ |
||
| 1198 | public static function assertNull($actual, $message = '') |
||
| 1202 | |||
| 1203 | /** |
||
| 1204 | * Asserts that a variable is not null. |
||
| 1205 | * |
||
| 1206 | * @param mixed $actual |
||
| 1207 | * @param string $message |
||
| 1208 | */ |
||
| 1209 | public static function assertNotNull($actual, $message = '') |
||
| 1213 | |||
| 1214 | /** |
||
| 1215 | * Asserts that a variable is finite. |
||
| 1216 | * |
||
| 1217 | * @param mixed $actual |
||
| 1218 | * @param string $message |
||
| 1219 | */ |
||
| 1220 | public static function assertFinite($actual, $message = '') |
||
| 1224 | |||
| 1225 | /** |
||
| 1226 | * Asserts that a variable is infinite. |
||
| 1227 | * |
||
| 1228 | * @param mixed $actual |
||
| 1229 | * @param string $message |
||
| 1230 | */ |
||
| 1231 | public static function assertInfinite($actual, $message = '') |
||
| 1235 | |||
| 1236 | /** |
||
| 1237 | * Asserts that a variable is nan. |
||
| 1238 | * |
||
| 1239 | * @param mixed $actual |
||
| 1240 | * @param string $message |
||
| 1241 | */ |
||
| 1242 | public static function assertNan($actual, $message = '') |
||
| 1246 | |||
| 1247 | /** |
||
| 1248 | * Asserts that a class has a specified attribute. |
||
| 1249 | * |
||
| 1250 | * @param string $attributeName |
||
| 1251 | * @param string $className |
||
| 1252 | * @param string $message |
||
| 1253 | */ |
||
| 1254 | public static function assertClassHasAttribute($attributeName, $className, $message = '') |
||
| 1274 | |||
| 1275 | /** |
||
| 1276 | * Asserts that a class does not have a specified attribute. |
||
| 1277 | * |
||
| 1278 | * @param string $attributeName |
||
| 1279 | * @param string $className |
||
| 1280 | * @param string $message |
||
| 1281 | */ |
||
| 1282 | public static function assertClassNotHasAttribute($attributeName, $className, $message = '') |
||
| 1302 | |||
| 1303 | /** |
||
| 1304 | * Asserts that a class has a specified static attribute. |
||
| 1305 | * |
||
| 1306 | * @param string $attributeName |
||
| 1307 | * @param string $className |
||
| 1308 | * @param string $message |
||
| 1309 | */ |
||
| 1310 | public static function assertClassHasStaticAttribute($attributeName, $className, $message = '') |
||
| 1330 | |||
| 1331 | /** |
||
| 1332 | * Asserts that a class does not have a specified static attribute. |
||
| 1333 | * |
||
| 1334 | * @param string $attributeName |
||
| 1335 | * @param string $className |
||
| 1336 | * @param string $message |
||
| 1337 | */ |
||
| 1338 | public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') |
||
| 1360 | |||
| 1361 | /** |
||
| 1362 | * Asserts that an object has a specified attribute. |
||
| 1363 | * |
||
| 1364 | * @param string $attributeName |
||
| 1365 | * @param object $object |
||
| 1366 | * @param string $message |
||
| 1367 | */ |
||
| 1368 | public static function assertObjectHasAttribute($attributeName, $object, $message = '') |
||
| 1388 | |||
| 1389 | /** |
||
| 1390 | * Asserts that an object does not have a specified attribute. |
||
| 1391 | * |
||
| 1392 | * @param string $attributeName |
||
| 1393 | * @param object $object |
||
| 1394 | * @param string $message |
||
| 1395 | */ |
||
| 1396 | public static function assertObjectNotHasAttribute($attributeName, $object, $message = '') |
||
| 1416 | |||
| 1417 | /** |
||
| 1418 | * Asserts that two variables have the same type and value. |
||
| 1419 | * Used on objects, it asserts that two variables reference |
||
| 1420 | * the same object. |
||
| 1421 | * |
||
| 1422 | * @param mixed $expected |
||
| 1423 | * @param mixed $actual |
||
| 1424 | * @param string $message |
||
| 1425 | */ |
||
| 1426 | public static function assertSame($expected, $actual, $message = '') |
||
| 1438 | |||
| 1439 | /** |
||
| 1440 | * Asserts that a variable and an attribute of an object have the same type |
||
| 1441 | * and value. |
||
| 1442 | * |
||
| 1443 | * @param mixed $expected |
||
| 1444 | * @param string $actualAttributeName |
||
| 1445 | * @param string|object $actualClassOrObject |
||
| 1446 | * @param string $message |
||
| 1447 | */ |
||
| 1448 | public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
| 1456 | |||
| 1457 | /** |
||
| 1458 | * Asserts that two variables do not have the same type and value. |
||
| 1459 | * Used on objects, it asserts that two variables do not reference |
||
| 1460 | * the same object. |
||
| 1461 | * |
||
| 1462 | * @param mixed $expected |
||
| 1463 | * @param mixed $actual |
||
| 1464 | * @param string $message |
||
| 1465 | */ |
||
| 1466 | public static function assertNotSame($expected, $actual, $message = '') |
||
| 1478 | |||
| 1479 | /** |
||
| 1480 | * Asserts that a variable and an attribute of an object do not have the |
||
| 1481 | * same type and value. |
||
| 1482 | * |
||
| 1483 | * @param mixed $expected |
||
| 1484 | * @param string $actualAttributeName |
||
| 1485 | * @param string|object $actualClassOrObject |
||
| 1486 | * @param string $message |
||
| 1487 | */ |
||
| 1488 | public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
||
| 1496 | |||
| 1497 | /** |
||
| 1498 | * Asserts that a variable is of a given type. |
||
| 1499 | * |
||
| 1500 | * @param string $expected |
||
| 1501 | * @param mixed $actual |
||
| 1502 | * @param string $message |
||
| 1503 | */ |
||
| 1504 | public static function assertInstanceOf($expected, $actual, $message = '') |
||
| 1516 | |||
| 1517 | /** |
||
| 1518 | * Asserts that an attribute is of a given type. |
||
| 1519 | * |
||
| 1520 | * @param string $expected |
||
| 1521 | * @param string $attributeName |
||
| 1522 | * @param string|object $classOrObject |
||
| 1523 | * @param string $message |
||
| 1524 | */ |
||
| 1525 | public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') |
||
| 1533 | |||
| 1534 | /** |
||
| 1535 | * Asserts that a variable is not of a given type. |
||
| 1536 | * |
||
| 1537 | * @param string $expected |
||
| 1538 | * @param mixed $actual |
||
| 1539 | * @param string $message |
||
| 1540 | */ |
||
| 1541 | public static function assertNotInstanceOf($expected, $actual, $message = '') |
||
| 1553 | |||
| 1554 | /** |
||
| 1555 | * Asserts that an attribute is of a given type. |
||
| 1556 | * |
||
| 1557 | * @param string $expected |
||
| 1558 | * @param string $attributeName |
||
| 1559 | * @param string|object $classOrObject |
||
| 1560 | * @param string $message |
||
| 1561 | */ |
||
| 1562 | public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') |
||
| 1570 | |||
| 1571 | /** |
||
| 1572 | * Asserts that a variable is of a given type. |
||
| 1573 | * |
||
| 1574 | * @param string $expected |
||
| 1575 | * @param mixed $actual |
||
| 1576 | * @param string $message |
||
| 1577 | */ |
||
| 1578 | public static function assertInternalType($expected, $actual, $message = '') |
||
| 1590 | |||
| 1591 | /** |
||
| 1592 | * Asserts that an attribute is of a given type. |
||
| 1593 | * |
||
| 1594 | * @param string $expected |
||
| 1595 | * @param string $attributeName |
||
| 1596 | * @param string|object $classOrObject |
||
| 1597 | * @param string $message |
||
| 1598 | */ |
||
| 1599 | public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') |
||
| 1607 | |||
| 1608 | /** |
||
| 1609 | * Asserts that a variable is not of a given type. |
||
| 1610 | * |
||
| 1611 | * @param string $expected |
||
| 1612 | * @param mixed $actual |
||
| 1613 | * @param string $message |
||
| 1614 | */ |
||
| 1615 | public static function assertNotInternalType($expected, $actual, $message = '') |
||
| 1627 | |||
| 1628 | /** |
||
| 1629 | * Asserts that an attribute is of a given type. |
||
| 1630 | * |
||
| 1631 | * @param string $expected |
||
| 1632 | * @param string $attributeName |
||
| 1633 | * @param string|object $classOrObject |
||
| 1634 | * @param string $message |
||
| 1635 | */ |
||
| 1636 | public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') |
||
| 1644 | |||
| 1645 | /** |
||
| 1646 | * Asserts that a string matches a given regular expression. |
||
| 1647 | * |
||
| 1648 | * @param string $pattern |
||
| 1649 | * @param string $string |
||
| 1650 | * @param string $message |
||
| 1651 | */ |
||
| 1652 | public static function assertRegExp($pattern, $string, $message = '') |
||
| 1666 | |||
| 1667 | /** |
||
| 1668 | * Asserts that a string does not match a given regular expression. |
||
| 1669 | * |
||
| 1670 | * @param string $pattern |
||
| 1671 | * @param string $string |
||
| 1672 | * @param string $message |
||
| 1673 | */ |
||
| 1674 | public static function assertNotRegExp($pattern, $string, $message = '') |
||
| 1690 | |||
| 1691 | /** |
||
| 1692 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) |
||
| 1693 | * is the same. |
||
| 1694 | * |
||
| 1695 | * @param array|Countable|Traversable $expected |
||
| 1696 | * @param array|Countable|Traversable $actual |
||
| 1697 | * @param string $message |
||
| 1698 | */ |
||
| 1699 | public static function assertSameSize($expected, $actual, $message = '') |
||
| 1719 | |||
| 1720 | /** |
||
| 1721 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) |
||
| 1722 | * is not the same. |
||
| 1723 | * |
||
| 1724 | * @param array|Countable|Traversable $expected |
||
| 1725 | * @param array|Countable|Traversable $actual |
||
| 1726 | * @param string $message |
||
| 1727 | */ |
||
| 1728 | public static function assertNotSameSize($expected, $actual, $message = '') |
||
| 1748 | |||
| 1749 | /** |
||
| 1750 | * Asserts that a string matches a given format string. |
||
| 1751 | * |
||
| 1752 | * @param string $format |
||
| 1753 | * @param string $string |
||
| 1754 | * @param string $message |
||
| 1755 | */ |
||
| 1756 | public static function assertStringMatchesFormat($format, $string, $message = '') |
||
| 1770 | |||
| 1771 | /** |
||
| 1772 | * Asserts that a string does not match a given format string. |
||
| 1773 | * |
||
| 1774 | * @param string $format |
||
| 1775 | * @param string $string |
||
| 1776 | * @param string $message |
||
| 1777 | */ |
||
| 1778 | public static function assertStringNotMatchesFormat($format, $string, $message = '') |
||
| 1794 | |||
| 1795 | /** |
||
| 1796 | * Asserts that a string matches a given format file. |
||
| 1797 | * |
||
| 1798 | * @param string $formatFile |
||
| 1799 | * @param string $string |
||
| 1800 | * @param string $message |
||
| 1801 | */ |
||
| 1802 | public static function assertStringMatchesFormatFile($formatFile, $string, $message = '') |
||
| 1816 | |||
| 1817 | /** |
||
| 1818 | * Asserts that a string does not match a given format string. |
||
| 1819 | * |
||
| 1820 | * @param string $formatFile |
||
| 1821 | * @param string $string |
||
| 1822 | * @param string $message |
||
| 1823 | */ |
||
| 1824 | public static function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') |
||
| 1840 | |||
| 1841 | /** |
||
| 1842 | * Asserts that a string starts with a given prefix. |
||
| 1843 | * |
||
| 1844 | * @param string $prefix |
||
| 1845 | * @param string $string |
||
| 1846 | * @param string $message |
||
| 1847 | */ |
||
| 1848 | public static function assertStringStartsWith($prefix, $string, $message = '') |
||
| 1864 | |||
| 1865 | /** |
||
| 1866 | * Asserts that a string starts not with a given prefix. |
||
| 1867 | * |
||
| 1868 | * @param string $prefix |
||
| 1869 | * @param string $string |
||
| 1870 | * @param string $message |
||
| 1871 | */ |
||
| 1872 | public static function assertStringStartsNotWith($prefix, $string, $message = '') |
||
| 1888 | |||
| 1889 | /** |
||
| 1890 | * Asserts that a string ends with a given suffix. |
||
| 1891 | * |
||
| 1892 | * @param string $suffix |
||
| 1893 | * @param string $string |
||
| 1894 | * @param string $message |
||
| 1895 | */ |
||
| 1896 | public static function assertStringEndsWith($suffix, $string, $message = '') |
||
| 1910 | |||
| 1911 | /** |
||
| 1912 | * Asserts that a string ends not with a given suffix. |
||
| 1913 | * |
||
| 1914 | * @param string $suffix |
||
| 1915 | * @param string $string |
||
| 1916 | * @param string $message |
||
| 1917 | */ |
||
| 1918 | public static function assertStringEndsNotWith($suffix, $string, $message = '') |
||
| 1934 | |||
| 1935 | /** |
||
| 1936 | * Asserts that two XML files are equal. |
||
| 1937 | * |
||
| 1938 | * @param string $expectedFile |
||
| 1939 | * @param string $actualFile |
||
| 1940 | * @param string $message |
||
| 1941 | */ |
||
| 1942 | public static function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') |
||
| 1949 | |||
| 1950 | /** |
||
| 1951 | * Asserts that two XML files are not equal. |
||
| 1952 | * |
||
| 1953 | * @param string $expectedFile |
||
| 1954 | * @param string $actualFile |
||
| 1955 | * @param string $message |
||
| 1956 | */ |
||
| 1957 | public static function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') |
||
| 1964 | |||
| 1965 | /** |
||
| 1966 | * Asserts that two XML documents are equal. |
||
| 1967 | * |
||
| 1968 | * @param string $expectedFile |
||
| 1969 | * @param string|DOMDocument $actualXml |
||
| 1970 | * @param string $message |
||
| 1971 | */ |
||
| 1972 | public static function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') |
||
| 1979 | |||
| 1980 | /** |
||
| 1981 | * Asserts that two XML documents are not equal. |
||
| 1982 | * |
||
| 1983 | * @param string $expectedFile |
||
| 1984 | * @param string|DOMDocument $actualXml |
||
| 1985 | * @param string $message |
||
| 1986 | */ |
||
| 1987 | public static function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') |
||
| 1994 | |||
| 1995 | /** |
||
| 1996 | * Asserts that two XML documents are equal. |
||
| 1997 | * |
||
| 1998 | * @param string|DOMDocument $expectedXml |
||
| 1999 | * @param string|DOMDocument $actualXml |
||
| 2000 | * @param string $message |
||
| 2001 | */ |
||
| 2002 | public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') |
||
| 2009 | |||
| 2010 | /** |
||
| 2011 | * Asserts that two XML documents are not equal. |
||
| 2012 | * |
||
| 2013 | * @param string|DOMDocument $expectedXml |
||
| 2014 | * @param string|DOMDocument $actualXml |
||
| 2015 | * @param string $message |
||
| 2016 | */ |
||
| 2017 | public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') |
||
| 2024 | |||
| 2025 | /** |
||
| 2026 | * Asserts that a hierarchy of DOMElements matches. |
||
| 2027 | * |
||
| 2028 | * @param DOMElement $expectedElement |
||
| 2029 | * @param DOMElement $actualElement |
||
| 2030 | * @param bool $checkAttributes |
||
| 2031 | * @param string $message |
||
| 2032 | */ |
||
| 2033 | public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = false, $message = '') |
||
| 2104 | |||
| 2105 | /** |
||
| 2106 | * Evaluates a PHPUnit_Framework_Constraint matcher object. |
||
| 2107 | * |
||
| 2108 | * @param mixed $value |
||
| 2109 | * @param Constraint $constraint |
||
| 2110 | * @param string $message |
||
| 2111 | */ |
||
| 2112 | public static function assertThat($value, Constraint $constraint, $message = '') |
||
| 2118 | |||
| 2119 | /** |
||
| 2120 | * Asserts that a string is a valid JSON string. |
||
| 2121 | * |
||
| 2122 | * @param string $actualJson |
||
| 2123 | * @param string $message |
||
| 2124 | */ |
||
| 2125 | public static function assertJson($actualJson, $message = '') |
||
| 2133 | |||
| 2134 | /** |
||
| 2135 | * Asserts that two given JSON encoded objects or arrays are equal. |
||
| 2136 | * |
||
| 2137 | * @param string $expectedJson |
||
| 2138 | * @param string $actualJson |
||
| 2139 | * @param string $message |
||
| 2140 | */ |
||
| 2141 | public static function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') |
||
| 2152 | |||
| 2153 | /** |
||
| 2154 | * Asserts that two given JSON encoded objects or arrays are not equal. |
||
| 2155 | * |
||
| 2156 | * @param string $expectedJson |
||
| 2157 | * @param string $actualJson |
||
| 2158 | * @param string $message |
||
| 2159 | */ |
||
| 2160 | public static function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') |
||
| 2171 | |||
| 2172 | /** |
||
| 2173 | * Asserts that the generated JSON encoded object and the content of the given file are equal. |
||
| 2174 | * |
||
| 2175 | * @param string $expectedFile |
||
| 2176 | * @param string $actualJson |
||
| 2177 | * @param string $message |
||
| 2178 | */ |
||
| 2179 | public static function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '') |
||
| 2193 | |||
| 2194 | /** |
||
| 2195 | * Asserts that the generated JSON encoded object and the content of the given file are not equal. |
||
| 2196 | * |
||
| 2197 | * @param string $expectedFile |
||
| 2198 | * @param string $actualJson |
||
| 2199 | * @param string $message |
||
| 2200 | */ |
||
| 2201 | public static function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') |
||
| 2215 | |||
| 2216 | /** |
||
| 2217 | * Asserts that two JSON files are equal. |
||
| 2218 | * |
||
| 2219 | * @param string $expectedFile |
||
| 2220 | * @param string $actualFile |
||
| 2221 | * @param string $message |
||
| 2222 | */ |
||
| 2223 | public static function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') |
||
| 2243 | |||
| 2244 | /** |
||
| 2245 | * Asserts that two JSON files are not equal. |
||
| 2246 | * |
||
| 2247 | * @param string $expectedFile |
||
| 2248 | * @param string $actualFile |
||
| 2249 | * @param string $message |
||
| 2250 | */ |
||
| 2251 | public static function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '') |
||
| 2271 | |||
| 2272 | /** |
||
| 2273 | * Returns a PHPUnit_Framework_Constraint_And matcher object. |
||
| 2274 | * |
||
| 2275 | * @return LogicalAnd |
||
| 2276 | */ |
||
| 2277 | public static function logicalAnd() |
||
| 2286 | |||
| 2287 | /** |
||
| 2288 | * Returns a PHPUnit_Framework_Constraint_Or matcher object. |
||
| 2289 | * |
||
| 2290 | * @return LogicalOr |
||
| 2291 | */ |
||
| 2292 | public static function logicalOr() |
||
| 2301 | |||
| 2302 | /** |
||
| 2303 | * Returns a PHPUnit_Framework_Constraint_Not matcher object. |
||
| 2304 | * |
||
| 2305 | * @param Constraint $constraint |
||
| 2306 | * |
||
| 2307 | * @return LogicalNot |
||
| 2308 | */ |
||
| 2309 | public static function logicalNot(Constraint $constraint) |
||
| 2313 | |||
| 2314 | /** |
||
| 2315 | * Returns a PHPUnit_Framework_Constraint_Xor matcher object. |
||
| 2316 | * |
||
| 2317 | * @return LogicalXor |
||
| 2318 | */ |
||
| 2319 | public static function logicalXor() |
||
| 2328 | |||
| 2329 | /** |
||
| 2330 | * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object. |
||
| 2331 | * |
||
| 2332 | * @return IsAnything |
||
| 2333 | */ |
||
| 2334 | public static function anything() |
||
| 2338 | |||
| 2339 | /** |
||
| 2340 | * Returns a PHPUnit_Framework_Constraint_IsTrue matcher object. |
||
| 2341 | * |
||
| 2342 | * @return IsTrue |
||
| 2343 | */ |
||
| 2344 | public static function isTrue() |
||
| 2348 | |||
| 2349 | /** |
||
| 2350 | * Returns a PHPUnit_Framework_Constraint_Callback matcher object. |
||
| 2351 | * |
||
| 2352 | * @param callable $callback |
||
| 2353 | * |
||
| 2354 | * @return Callback |
||
| 2355 | */ |
||
| 2356 | public static function callback($callback) |
||
| 2360 | |||
| 2361 | /** |
||
| 2362 | * Returns a PHPUnit_Framework_Constraint_IsFalse matcher object. |
||
| 2363 | * |
||
| 2364 | * @return IsFalse |
||
| 2365 | */ |
||
| 2366 | public static function isFalse() |
||
| 2370 | |||
| 2371 | /** |
||
| 2372 | * Returns a PHPUnit_Framework_Constraint_IsJson matcher object. |
||
| 2373 | * |
||
| 2374 | * @return IsJson |
||
| 2375 | */ |
||
| 2376 | public static function isJson() |
||
| 2380 | |||
| 2381 | /** |
||
| 2382 | * Returns a PHPUnit_Framework_Constraint_IsNull matcher object. |
||
| 2383 | * |
||
| 2384 | * @return IsNull |
||
| 2385 | */ |
||
| 2386 | public static function isNull() |
||
| 2390 | |||
| 2391 | /** |
||
| 2392 | * Returns a PHPUnit_Framework_Constraint_IsFinite matcher object. |
||
| 2393 | * |
||
| 2394 | * @return IsFinite |
||
| 2395 | */ |
||
| 2396 | public static function isFinite() |
||
| 2400 | |||
| 2401 | /** |
||
| 2402 | * Returns a PHPUnit_Framework_Constraint_IsInfinite matcher object. |
||
| 2403 | * |
||
| 2404 | * @return IsInfinite |
||
| 2405 | */ |
||
| 2406 | public static function isInfinite() |
||
| 2410 | |||
| 2411 | /** |
||
| 2412 | * Returns a PHPUnit_Framework_Constraint_IsNan matcher object. |
||
| 2413 | * |
||
| 2414 | * @return IsNan |
||
| 2415 | */ |
||
| 2416 | public static function isNan() |
||
| 2420 | |||
| 2421 | /** |
||
| 2422 | * Returns a PHPUnit_Framework_Constraint_Attribute matcher object. |
||
| 2423 | * |
||
| 2424 | * @param Constraint $constraint |
||
| 2425 | * @param string $attributeName |
||
| 2426 | * |
||
| 2427 | * @return Attribute |
||
| 2428 | */ |
||
| 2429 | public static function attribute(Constraint $constraint, $attributeName) |
||
| 2436 | |||
| 2437 | /** |
||
| 2438 | * Returns a PHPUnit_Framework_Constraint_TraversableContains matcher |
||
| 2439 | * object. |
||
| 2440 | * |
||
| 2441 | * @param mixed $value |
||
| 2442 | * @param bool $checkForObjectIdentity |
||
| 2443 | * @param bool $checkForNonObjectIdentity |
||
| 2444 | * |
||
| 2445 | * @return TraversableContains |
||
| 2446 | */ |
||
| 2447 | public static function contains($value, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
||
| 2451 | |||
| 2452 | /** |
||
| 2453 | * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher |
||
| 2454 | * object. |
||
| 2455 | * |
||
| 2456 | * @param string $type |
||
| 2457 | * |
||
| 2458 | * @return TraversableContainsOnly |
||
| 2459 | */ |
||
| 2460 | public static function containsOnly($type) |
||
| 2464 | |||
| 2465 | /** |
||
| 2466 | * Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher |
||
| 2467 | * object. |
||
| 2468 | * |
||
| 2469 | * @param string $classname |
||
| 2470 | * |
||
| 2471 | * @return TraversableContainsOnly |
||
| 2472 | */ |
||
| 2473 | public static function containsOnlyInstancesOf($classname) |
||
| 2477 | |||
| 2478 | /** |
||
| 2479 | * Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object. |
||
| 2480 | * |
||
| 2481 | * @param mixed $key |
||
| 2482 | * |
||
| 2483 | * @return ArrayHasKey |
||
| 2484 | */ |
||
| 2485 | public static function arrayHasKey($key) |
||
| 2489 | |||
| 2490 | /** |
||
| 2491 | * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object. |
||
| 2492 | * |
||
| 2493 | * @param mixed $value |
||
| 2494 | * @param float $delta |
||
| 2495 | * @param int $maxDepth |
||
| 2496 | * @param bool $canonicalize |
||
| 2497 | * @param bool $ignoreCase |
||
| 2498 | * |
||
| 2499 | * @return IsEqual |
||
| 2500 | */ |
||
| 2501 | public static function equalTo($value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
| 2511 | |||
| 2512 | /** |
||
| 2513 | * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object |
||
| 2514 | * that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher |
||
| 2515 | * object. |
||
| 2516 | * |
||
| 2517 | * @param string $attributeName |
||
| 2518 | * @param mixed $value |
||
| 2519 | * @param float $delta |
||
| 2520 | * @param int $maxDepth |
||
| 2521 | * @param bool $canonicalize |
||
| 2522 | * @param bool $ignoreCase |
||
| 2523 | * |
||
| 2524 | * @return Attribute |
||
| 2525 | */ |
||
| 2526 | public static function attributeEqualTo($attributeName, $value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
||
| 2539 | |||
| 2540 | /** |
||
| 2541 | * Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object. |
||
| 2542 | * |
||
| 2543 | * @return IsEmpty |
||
| 2544 | */ |
||
| 2545 | public static function isEmpty() |
||
| 2549 | |||
| 2550 | /** |
||
| 2551 | * Returns a PHPUnit_Framework_Constraint_IsWritable matcher object. |
||
| 2552 | * |
||
| 2553 | * @return IsWritable |
||
| 2554 | */ |
||
| 2555 | public static function isWritable() |
||
| 2559 | |||
| 2560 | /** |
||
| 2561 | * Returns a PHPUnit_Framework_Constraint_IsReadable matcher object. |
||
| 2562 | * |
||
| 2563 | * @return IsReadable |
||
| 2564 | */ |
||
| 2565 | public static function isReadable() |
||
| 2569 | |||
| 2570 | /** |
||
| 2571 | * Returns a PHPUnit_Framework_Constraint_DirectoryExists matcher object. |
||
| 2572 | * |
||
| 2573 | * @return DirectoryExists |
||
| 2574 | */ |
||
| 2575 | public static function directoryExists() |
||
| 2579 | |||
| 2580 | /** |
||
| 2581 | * Returns a PHPUnit_Framework_Constraint_FileExists matcher object. |
||
| 2582 | * |
||
| 2583 | * @return FileExists |
||
| 2584 | */ |
||
| 2585 | public static function fileExists() |
||
| 2589 | |||
| 2590 | /** |
||
| 2591 | * Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object. |
||
| 2592 | * |
||
| 2593 | * @param mixed $value |
||
| 2594 | * |
||
| 2595 | * @return GreaterThan |
||
| 2596 | */ |
||
| 2597 | public static function greaterThan($value) |
||
| 2601 | |||
| 2602 | /** |
||
| 2603 | * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps |
||
| 2604 | * a PHPUnit_Framework_Constraint_IsEqual and a |
||
| 2605 | * PHPUnit_Framework_Constraint_GreaterThan matcher object. |
||
| 2606 | * |
||
| 2607 | * @param mixed $value |
||
| 2608 | * |
||
| 2609 | * @return LogicalOr |
||
| 2610 | */ |
||
| 2611 | public static function greaterThanOrEqual($value) |
||
| 2618 | |||
| 2619 | /** |
||
| 2620 | * Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object. |
||
| 2621 | * |
||
| 2622 | * @param string $attributeName |
||
| 2623 | * |
||
| 2624 | * @return ClassHasAttribute |
||
| 2625 | */ |
||
| 2626 | public static function classHasAttribute($attributeName) |
||
| 2632 | |||
| 2633 | /** |
||
| 2634 | * Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher |
||
| 2635 | * object. |
||
| 2636 | * |
||
| 2637 | * @param string $attributeName |
||
| 2638 | * |
||
| 2639 | * @return ClassHasStaticAttribute |
||
| 2640 | */ |
||
| 2641 | public static function classHasStaticAttribute($attributeName) |
||
| 2647 | |||
| 2648 | /** |
||
| 2649 | * Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object. |
||
| 2650 | * |
||
| 2651 | * @param string $attributeName |
||
| 2652 | * |
||
| 2653 | * @return ObjectHasAttribute |
||
| 2654 | */ |
||
| 2655 | public static function objectHasAttribute($attributeName) |
||
| 2661 | |||
| 2662 | /** |
||
| 2663 | * Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object. |
||
| 2664 | * |
||
| 2665 | * @param mixed $value |
||
| 2666 | * |
||
| 2667 | * @return IsIdentical |
||
| 2668 | */ |
||
| 2669 | public static function identicalTo($value) |
||
| 2673 | |||
| 2674 | /** |
||
| 2675 | * Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object. |
||
| 2676 | * |
||
| 2677 | * @param string $className |
||
| 2678 | * |
||
| 2679 | * @return IsInstanceOf |
||
| 2680 | */ |
||
| 2681 | public static function isInstanceOf($className) |
||
| 2685 | |||
| 2686 | /** |
||
| 2687 | * Returns a PHPUnit_Framework_Constraint_IsType matcher object. |
||
| 2688 | * |
||
| 2689 | * @param string $type |
||
| 2690 | * |
||
| 2691 | * @return IsType |
||
| 2692 | */ |
||
| 2693 | public static function isType($type) |
||
| 2697 | |||
| 2698 | /** |
||
| 2699 | * Returns a PHPUnit_Framework_Constraint_LessThan matcher object. |
||
| 2700 | * |
||
| 2701 | * @param mixed $value |
||
| 2702 | * |
||
| 2703 | * @return LessThan |
||
| 2704 | */ |
||
| 2705 | public static function lessThan($value) |
||
| 2709 | |||
| 2710 | /** |
||
| 2711 | * Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps |
||
| 2712 | * a PHPUnit_Framework_Constraint_IsEqual and a |
||
| 2713 | * PHPUnit_Framework_Constraint_LessThan matcher object. |
||
| 2714 | * |
||
| 2715 | * @param mixed $value |
||
| 2716 | * |
||
| 2717 | * @return LogicalOr |
||
| 2718 | */ |
||
| 2719 | public static function lessThanOrEqual($value) |
||
| 2726 | |||
| 2727 | /** |
||
| 2728 | * Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object. |
||
| 2729 | * |
||
| 2730 | * @param string $pattern |
||
| 2731 | * |
||
| 2732 | * @return RegularExpression |
||
| 2733 | */ |
||
| 2734 | public static function matchesRegularExpression($pattern) |
||
| 2738 | |||
| 2739 | /** |
||
| 2740 | * Returns a PHPUnit_Framework_Constraint_StringMatches matcher object. |
||
| 2741 | * |
||
| 2742 | * @param string $string |
||
| 2743 | * |
||
| 2744 | * @return StringMatchesFormatDescription |
||
| 2745 | */ |
||
| 2746 | public static function matches($string) |
||
| 2750 | |||
| 2751 | /** |
||
| 2752 | * Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object. |
||
| 2753 | * |
||
| 2754 | * @param mixed $prefix |
||
| 2755 | * |
||
| 2756 | * @return StringStartsWith |
||
| 2757 | */ |
||
| 2758 | public static function stringStartsWith($prefix) |
||
| 2762 | |||
| 2763 | /** |
||
| 2764 | * Returns a PHPUnit_Framework_Constraint_StringContains matcher object. |
||
| 2765 | * |
||
| 2766 | * @param string $string |
||
| 2767 | * @param bool $case |
||
| 2768 | * |
||
| 2769 | * @return StringContains |
||
| 2770 | */ |
||
| 2771 | public static function stringContains($string, $case = true) |
||
| 2775 | |||
| 2776 | /** |
||
| 2777 | * Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object. |
||
| 2778 | * |
||
| 2779 | * @param mixed $suffix |
||
| 2780 | * |
||
| 2781 | * @return StringEndsWith |
||
| 2782 | */ |
||
| 2783 | public static function stringEndsWith($suffix) |
||
| 2787 | |||
| 2788 | /** |
||
| 2789 | * Returns a PHPUnit_Framework_Constraint_Count matcher object. |
||
| 2790 | * |
||
| 2791 | * @param int $count |
||
| 2792 | * |
||
| 2793 | * @return Count |
||
| 2794 | */ |
||
| 2795 | public static function countOf($count) |
||
| 2799 | |||
| 2800 | /** |
||
| 2801 | * Fails a test with the given message. |
||
| 2802 | * |
||
| 2803 | * @param string $message |
||
| 2804 | * |
||
| 2805 | * @throws AssertionFailedError |
||
| 2806 | */ |
||
| 2807 | public static function fail($message = '') |
||
| 2813 | |||
| 2814 | /** |
||
| 2815 | * Returns the value of an attribute of a class or an object. |
||
| 2816 | * This also works for attributes that are declared protected or private. |
||
| 2817 | * |
||
| 2818 | * @param string|object $classOrObject |
||
| 2819 | * @param string $attributeName |
||
| 2820 | * |
||
| 2821 | * @return mixed |
||
| 2822 | * |
||
| 2823 | * @throws Exception |
||
| 2824 | */ |
||
| 2825 | public static function readAttribute($classOrObject, $attributeName) |
||
| 2861 | |||
| 2862 | /** |
||
| 2863 | * Returns the value of a static attribute. |
||
| 2864 | * This also works for attributes that are declared protected or private. |
||
| 2865 | * |
||
| 2866 | * @param string $className |
||
| 2867 | * @param string $attributeName |
||
| 2868 | * |
||
| 2869 | * @return mixed |
||
| 2870 | * |
||
| 2871 | * @throws Exception |
||
| 2872 | */ |
||
| 2873 | public static function getStaticAttribute($className, $attributeName) |
||
| 2910 | |||
| 2911 | /** |
||
| 2912 | * Returns the value of an object's attribute. |
||
| 2913 | * This also works for attributes that are declared protected or private. |
||
| 2914 | * |
||
| 2915 | * @param object $object |
||
| 2916 | * @param string $attributeName |
||
| 2917 | * |
||
| 2918 | * @return mixed |
||
| 2919 | * |
||
| 2920 | * @throws Exception |
||
| 2921 | */ |
||
| 2922 | public static function getObjectAttribute($object, $attributeName) |
||
| 2969 | |||
| 2970 | /** |
||
| 2971 | * Mark the test as incomplete. |
||
| 2972 | * |
||
| 2973 | * @param string $message |
||
| 2974 | * |
||
| 2975 | * @throws IncompleteTestError |
||
| 2976 | */ |
||
| 2977 | public static function markTestIncomplete($message = '') |
||
| 2981 | |||
| 2982 | /** |
||
| 2983 | * Mark the test as skipped. |
||
| 2984 | * |
||
| 2985 | * @param string $message |
||
| 2986 | * |
||
| 2987 | * @throws SkippedTestError |
||
| 2988 | */ |
||
| 2989 | public static function markTestSkipped($message = '') |
||
| 2993 | |||
| 2994 | /** |
||
| 2995 | * Return the current assertion count. |
||
| 2996 | * |
||
| 2997 | * @return int |
||
| 2998 | */ |
||
| 2999 | public static function getCount() |
||
| 3003 | |||
| 3004 | /** |
||
| 3005 | * Reset the assertion counter. |
||
| 3006 | */ |
||
| 3007 | public static function resetCount() |
||
| 3011 | } |
||
| 3012 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.