removeById() public method

Remove an item in the collection by key
public removeById ( mixed $key ) : void
$key mixed
return void
Example #1
0
 /**
  * @group           DataModel
  * @group           CollectionRemoveById
  * @covers          FOF30\Model\DataModel\Collection::removeById
  * @dataProvider    CollectionDataprovider::getTestRemoveById
  */
 public function testRemoveById($test, $check)
 {
     $msg = 'Collection::removeById %s - Case: ' . $check['case'];
     $items = $this->buildCollection();
     $collection = new Collection($items);
     $key = $test['key'] == 'object' ? $items[2] : $test['key'];
     $collection->removeById($key);
     $this->assertArrayNotHasKey($check['key'], $collection, sprintf($msg, 'Failed to remove the item'));
 }