You are here

public function ArrayCollectionTest::testIndexOf in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php \Doctrine\Tests\Common\Collections\ArrayCollectionTest::testIndexOf()

File

vendor/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');
}