PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Testing » PHPUnit » Bug #2569

assertContains

Details

Submitted2004-10-19 13:49 UTC
Frominfo at e-novative dot de
StatusClosed
PackagePHPUnit
PHP Version5.0.2
OSWindows
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 ...?