示例#1
0
 public function testRemoveElement()
 {
     $elements = [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->assertSame($elements, $collection->toArray());
 }