assertContains is not type-safe for (non-object) primitive types #745

farnoux opened this Issue Dec 11, 2012 · 3 comments


None yet
4 participants

farnoux commented Dec 11, 2012

Currently the $checkForObjectIdentity parameter, as its name indicates, only check identity for object elements. Is there any reason the assertContains() method doesn't check identity also for primitive types?


$this->assertContains('hello', array(10, 45, 0)); // Success :(

This assert is unexpectedly successful due to the fact that 0 == 'hello' returns true.
This is successful whatever the value of the $checkForObjectIdentity parameter, because it only applies for elements of type Object.

farnoux pushed a commit to farnoux/phpunit that referenced this issue Dec 11, 2012

Appears to be an issue again with latest stable as of the date of this writing.

@mhousser Please open a new ticket that include a minimal, self-contained, reproducing test case.

#2111 here you go. easy for me to reproduce in 5.2.10.

@arothuis arothuis referenced this issue in OpenConext/OpenConext-engineblock Dec 19, 2016


Set AllowCreate correctly for SAML2 #371

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