public function test_iterator_remove_item_2() { $actual = ''; $coll = new Collection(); $coll->addItem('HelloWorld1', 'msg1'); $coll->addItem('HelloWorld2'); foreach ($coll as $key => $item) { if ($key == 'msg1') { $coll->removeItem($key); $actual = $item; } } $this->assertEquals('HelloWorld2', $actual); }