You are here

public function ArrayCollectionTest::testContains in Plug 7

File

lib/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php, line 228

Class

ArrayCollectionTest
Tests for { @covers \Doctrine\Common\Collections\ArrayCollection

Namespace

Doctrine\Tests\Common\Collections

Code

public function testContains() {
  $elements = array(
    1,
    'A' => 'a',
    2,
    'null' => null,
    3,
    'A2' => 'a',
    'zero' => 0,
  );
  $collection = new ArrayCollection($elements);
  $this
    ->assertTrue($collection
    ->contains(0), "Contains Zero");
  $this
    ->assertTrue($collection
    ->contains('a'), "Contains \"a\"");
  $this
    ->assertTrue($collection
    ->contains(null), "Contains Null");
  $this
    ->assertFalse($collection
    ->contains('non-existent'), "Doesn't contain an element");
}