I have a script that throws exceptions when something goes wrong. However, for the purposes of testing I also want to capture specific points although I'm not sure whether they would be deemed errors or not.
Below is an example:
if ($model->fetchCurrentlyProcessing() > 0) {
throw new App_Exception_CurrentProcess('There is a currently process running. Stopping process.');
}
if ($model->fetchQueuedItems() == 0) {
throw new App_Exception_NothingInQueue('Nothing in queue. Stopping process.');
}
In my tests I want to mock the response from these $model methods and detect which exception was thrown, and whether it was the expected exception or not. By throwing exceptions in these cases I can identify exactly at what point the script stopped. But I'm not sure if this is the correct usage of Exceptions as these possible aren't errors to be precise, as in nothing went wrong.