I'm new to unit testing and have written the following test:
/**
* @expectedException Exception
*/
public function testCantGetInvalidCampsite() {
$invalidIds = array(300000, "string");
foreach($invalidIds as $id) {
$this->campsites->getCampsite($id); // will throw an exception
}
}
I'm not sure though if this is actually testing all the invalid ids, or just stopping as soon as it hits the first exception. Is this how I should be testing for multiple exceptions or do I need to split this up into a number of different tests, or is there another way I should do it?
Also, if my exception message is generated dynamically eg "Could not retrieve record with id 30000", how do I test that the correct dynamic message is being produced?