Download the PHP package johnbillion/falsey-assertequals-detector without Composer
On this page you can find all versions of the php package johnbillion/falsey-assertequals-detector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download johnbillion/falsey-assertequals-detector
More information about johnbillion/falsey-assertequals-detector
Files in johnbillion/falsey-assertequals-detector
Package falsey-assertequals-detector
Short Description Detects usage of assertEquals() with falsey values and marks the test as risky.
License GPL-3.0+
Homepage https://github.com/johnbillion/falsey-assertequals-detector/
Informations about the package falsey-assertequals-detector
Falsey assertEquals Detector
This package will mark a PHPUnit test as risky if it tests a falsey value with assertEquals().
Why?
assertEquals() isn't type sensitive which means checking falsey values with it can result in tests passing when they shouldn't. For example, this assertion passes but it's probably unexpected:
Instead, assertSame() should be used when testing falsey values.
This package will mark a test as risky if it tests a falsey value with assertEquals() so that you can investigate the test and improve its assertions as necessary.
Falsey values include:
- An empty array
- An empty string
- Boolean
false - Float
0.0 - Integer
0 null- String
'0'
Installation
PHPUnit 7, 8, and 9 are supported.
- For PHPUnit 6 support, use version
^2. - For PHPUnit 5 support, use version
^1.
Usage
Use the trait in your base test class:
Any time one of your tests calls assertEquals(), the test will be marked as risky if either the expected value or the actual value are falsey.