You are here

public function ArrayCollectionTest::testRemoveElement in Plug 7

File

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

Class

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

Namespace

Doctrine\Tests\Common\Collections

Code

public function testRemoveElement() {
  $elements = array(
    1,
    'A' => 'a',
    2,
    'B' => 'b',
    3,
    'A2' => 'a',
    'B2' => 'b',
  );
  $collection = new ArrayCollection($elements);
  $this
    ->assertTrue($collection
    ->removeElement(1));
  unset($elements[0]);
  $this
    ->assertFalse($collection
    ->removeElement('non-existent'));
  $this
    ->assertTrue($collection
    ->removeElement('a'));
  unset($elements['A']);
  $this
    ->assertTrue($collection
    ->removeElement('a'));
  unset($elements['A2']);
  $this
    ->assertEquals($elements, $collection
    ->toArray());
}