public function ArrayCollectionTest::testExists in Plug 7
File
- lib/
doctrine/ collections/ tests/ Doctrine/ Tests/ Common/ Collections/ ArrayCollectionTest.php, line 239
Class
- ArrayCollectionTest
- Tests for { @covers \Doctrine\Common\Collections\ArrayCollection
Namespace
Doctrine\Tests\Common\CollectionsCode
public function testExists() {
$elements = array(
1,
'A' => 'a',
2,
'null' => null,
3,
'A2' => 'a',
'zero' => 0,
);
$collection = new ArrayCollection($elements);
$this
->assertTrue($collection
->exists(function ($key, $element) {
return $key == 'A' && $element == 'a';
}), "Element exists");
$this
->assertFalse($collection
->exists(function ($key, $element) {
return $key == 'non-existent' && $element == 'non-existent';
}), "Element not exists");
}