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

assertContains() and object equality #3511

sebastianbergmann opened this Issue Feb 5, 2019 · 0 comments


None yet
1 participant
Copy link

sebastianbergmann commented Feb 5, 2019

As part of #3422, assertStringContainsString(), assertStringContainsStringIgnoringCase(), assertStringNotContainsString(), and assertStringNotContainsStringIgnoringCase() were introduced in PHPUnit 7.5 to separate the use cases that operate on strings from assertContains(). This was good.

Also as part of #3422, and implemented in #3425, optional parameters for assertContains() that have an effect when non-string haystacks (read: iterable haystacks) are used, were deprecated. The result of this is that, once these optional parameters are completely removed in PHPUnit 9 (see #3426), there is currently no way to assert that an object is contained in an iterable while using == instead of ===. This is bad and something should be done about it.

The original implementation of #3422 in 2975888 introduced new assertions assertIterableContains() and assertIterableContainsSame(), for instance, to support the two separate use cases of asserting that an object is contained in an iterable, once using == and once using ===, respectively. This idea was abandoned in order to avoid additional backward compatibility breaks that would have resulted from deprecating the original assertContains() methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment