phpunit
phpunit copied to clipboard
`TestCase::assertEquals(false, '0')` is failing
| Q | A |
|---|---|
| PHPUnit version | 9.5.10 |
| PHP version | 7.4 |
| Installation Method | Composer |
Summary
TestCase::assertEquals(false, '0')
currently produces:
Failed asserting that '0' matches expected false.
and does NOT match the php weak comparison: https://3v4l.org/qQkXC
also $this->assertEquals(false, 0) passes, so TestCase::assertEquals(false, '0') should pass too and be consistent
changing https://github.com/sebastianbergmann/comparator/blob/main/src/ScalarComparator.php#L61 to
- if (is_string($expected) || is_string($actual)) {
+ if ((is_string($expected) && !is_bool($actual)) || (is_string($actual) && !is_bool($expected))) {
fixes the issue for me