Reputation: 62444
Unfortunately, PHP doesn't allow string type hinting. I want to check the below item and throw an error if it's not an instance of a certain class. Is it possible to unit test this, whether by mocking or performing this check some other way?
if (!is_array($schedules)) {
$schedules = array($schedules);
}
foreach ($schedules as $schedule) {
if (($schedule instanceOf Schedulable) === false) {
throw new ScheduleException('Schedule for "'.$command->getName().'" is not an instance of Schedulable');
}
//more stuff here
}
The trouble I'm running into is that $schedule
is a mock. and I need to test what happens in the //more stuff here
section.
Currently, $schedule
is an instance of Mockery::mock('Schedule');
.
Upvotes: 0
Views: 100
Reputation: 255005
As we have discussed in the comments one should ensure that:
Upvotes: 3