I have this Guard:
protected function validateRemove($key)
{
if (!isset($this->collection[$key])) {
throw new CategoryCollectionBadItemException();
}
}
And the test:
/**
* @test
* @expectedException InfluenceDecision\Domain\Exception\Category\CategoryCollectionBadItemException
*/
public function removeMethodMustThrowExceptionWithInvalidKey()
{
$this->categoryCollection->add(
new Category(
null,
'test category'
)
);
$this->categoryCollection->remove(1);
}
CategoryCollection remove method calls validateRemove method
The test works fine, but the coverage isn't 100% because the test can't access to the last line of validateRemove method:
What's the propper solution?