Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
farnoux opened this Issue · 0 comments

2 participants

@farnoux

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?

Example:

$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.

@whatthejeff whatthejeff closed this issue from a commit
@farnoux farnoux Allow identity checking for non object types in TraversableContains a…
…ssertions.

This fixes #745.
The possibility to check identity for non object is done by adding a new optional parameter.
This comes in addition to the existing one that already allow to check object identity or not.
255f5cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.