You are here

public function ArrayCollectionTest::testRemove in Plug 7

File

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

Class

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

Namespace

Doctrine\Tests\Common\Collections

Code

public function testRemove() {
  $elements = array(
    1,
    'A' => 'a',
    2,
    'B' => 'b',
    3,
  );
  $collection = new ArrayCollection($elements);
  $this
    ->assertEquals(1, $collection
    ->remove(0));
  unset($elements[0]);
  $this
    ->assertEquals(null, $collection
    ->remove('non-existent'));
  unset($elements['non-existent']);
  $this
    ->assertEquals(2, $collection
    ->remove(1));
  unset($elements[1]);
  $this
    ->assertEquals('a', $collection
    ->remove('A'));
  unset($elements['A']);
  $this
    ->assertEquals($elements, $collection
    ->toArray());
}