You are here

public function ArrayCollectionTest::testIndexOf in Plug 7

File

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

Class

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

Namespace

Doctrine\Tests\Common\Collections

Code

public function testIndexOf() {
  $elements = array(
    1,
    'A' => 'a',
    2,
    'null' => null,
    3,
    'A2' => 'a',
    'zero' => 0,
  );
  $collection = new ArrayCollection($elements);
  $this
    ->assertSame(array_search(2, $elements, true), $collection
    ->indexOf(2), 'Index of 2');
  $this
    ->assertSame(array_search(null, $elements, true), $collection
    ->indexOf(null), 'Index of null');
  $this
    ->assertSame(array_search('non-existent', $elements, true), $collection
    ->indexOf('non-existent'), 'Index of non existent');
}