Cheatography
https://cheatography.com
The most useful assertions and annotations of PHPUnit
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Installation
|
composer global require "phpunit/phpunit=4.8.*" |
php phpunit{.phar} --version |
Command Line - Test selection options
--filter <pattern> |
Filter which tests to run. |
--group ... |
Only runs tests from the specified group(s). |
--exclude-group ... |
Exclude tests from the specified group(s). |
--list-groups |
List available test groups. |
-c <configuration_file> |
Use configuration file to find testsuites |
Command Line - Execution options
--stop-on-error |
Stop execution upon first error. |
--stop-on-failure |
Stop execution upon first error or failure. |
--verbose |
Output more verbose information. |
--debug |
Display debugging information during test execution. |
--help |
Display usage information. |
|
|
Common assertions
assert{Not}Equals($a, $b), assert{Not}Same($a, $b) |
assertTrue($a), assertFalse($a), $assert{Not}Null($a) |
Type / Class assertions
assert{Not}InternalType($expectedType, $a) |
assert{Not}InstanceOf($expectedClass, $a) |
assertObject{Not}HasAttribute($attribute, $a) |
|
|
|