@darkninja462 You can't really unit test this as far as I am aware. What you need to do, is make a class with the functionality that is run within the closure, then unit test this. Thereafter, you just need to call the class via the scheduler and trust that the scheduler is working correctly calling it.
Mar 9, 2016
5
Level 1
Unit testing Task Scheduling?
Hi All, I'm currently writing a Task Schedule, which is defined by calling a closure within the Kernel schedule function as described by the docs.
The basic flow is
$schedule->call(
function () {
// delete some users where they match the criteria
// email the results
}
)
->timing()
->name("")
->withoutOverlapping();
I have simplified the code so easier to post but the basic flow is that.
I was wondering what is the best way to unit test this? or is there a better way to do this so it is easier to be unit tested?
Regards -Darkninja462
Please or to participate in this conversation.