Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in 3.0.4 and 4.0.7 #101

Closed
sebastianbergmann opened this issue Sep 14, 2022 · 3 comments
Closed

Regression in 3.0.4 and 4.0.7 #101

sebastianbergmann opened this issue Sep 14, 2022 · 3 comments
Labels

Comments

@sebastianbergmann
Copy link
Owner

After #99, there is now a failing test in PHPUnit's own test suite:

$ ./phpunit --filter testConstraintIsEqual2#7
PHPUnit 8.5.29-10-g1f265825a3 #StandWithUkraine

Runtime:       PHP 8.1.10 with PCOV 1.0.11
Configuration: /usr/local/src/phpunit/phpunit.xml

F                                                                   1 / 1 (100%)

Time: 154 ms, Memory: 14.00 MB

There was 1 failure:

1) PHPUnit\Framework\Constraint\IsEqualTest::testConstraintIsEqual2 with data set #7 (array(true), array('true'), 'Failed asserting that two arr...\n )\n')

/usr/local/src/phpunit/src/Framework/Assert.php:3383
/usr/local/src/phpunit/tests/unit/Framework/Constraint/IsEqualTest.php:72
/usr/local/src/phpunit/src/Framework/TestCase.php:1492
/usr/local/src/phpunit/src/Framework/TestCase.php:1112
/usr/local/src/phpunit/src/Framework/TestResult.php:703
/usr/local/src/phpunit/src/Framework/TestCase.php:838
/usr/local/src/phpunit/src/Framework/TestSuite.php:619
/usr/local/src/phpunit/src/Framework/TestSuite.php:619
/usr/local/src/phpunit/src/Framework/TestSuite.php:619
/usr/local/src/phpunit/src/Framework/TestSuite.php:619
/usr/local/src/phpunit/src/TextUI/TestRunner.php:659
/usr/local/src/phpunit/src/TextUI/Command.php:235
/usr/local/src/phpunit/src/TextUI/Command.php:194

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Before #99, PHPUnit's assertEquals() (which uses the code changed in the aforementioned PR) considered ['true'] == [true]. This is in line with PHP's behaviour of the == operator:

php > var_dump('true' == true);
bool(true)
php > var_dump(['true'] == [true]);
bool(true)
@sebastianbergmann
Copy link
Owner Author

CC @mvorisek

@sebastianbergmann
Copy link
Owner Author

This library seems to handle this case correctly, see commits 1ae7a68 and 7e3d8ea which add new tests that pass without production code changes.

@sebastianbergmann
Copy link
Owner Author

Nevermind, there is nothing wrong here. The test in PHPUnit's own test suite relied on wrong behaviour in this library that has now been fixed. This was not obvious to me at first glance because the test in question uses try/catch/return ... $this->fail() instead of expectException*() for verifying that the expected exception is raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant