Home » Testing » PHPUnit » Bug #2569
assertContains
Details
| Submitted | 2004-10-19 13:49 UTC |
|---|---|
| From | info at e-novative dot de |
| Status | Closed |
| Package | PHPUnit |
| PHP Version | 5.0.2 |
| OS | Windows |
| Roadmaps | (Not assigned) |
Comments
[2004-10-19 13:49 UTC] info at e-novative dot de
Description:
------------
assertContains in PHPUnit 1.1.0 does not work when the needle is an object and the haystack is an array of objects. Seems like line 48 of Assert.php should read
else if (is_array($haystack) && is_object($needle)) {
instead of
else if (is_array($haystack) && !is_object($needle)) {
Reproduce code:
---------------
$this->assertContains ($object, $array_of_objects);
Expected result:
----------------
true
Actual result:
--------------
Unsupported parameter passed to assertContains().
[2004-10-19 14:55 UTC] info at e-novative dot de
From the changelog:
+ Added PHPUnit_Assert::assertContains() and PHPUnit_Assert::assertNotContains() methods to assert that an array contains (or not contains) a given object or string or that a string contains (or not contains) a given substring.
This seems to be contradictory to your statement. So, it seems like the software and the changelog don't quite agree here ...?