[英]How do i check if a function is working fine without running it in the browser In PHP(Laravel 5.6)
这是我尝试运行的示例函数。
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$tickets = Ticketit::where('created_at', '<', Carbon::now()->subDays(1))->where('is_notified', false)->get();
foreach ($tickets as $ticket) {
//sending mail
$mail= $message->to('bonderi@strathmore.edu')->body('Your ticket is overdue');
}
})->hourly();
}
您应该签出PHPUnit并进行测试。 也许使用Mockery模拟对象。 默认情况下,它已包含在Laravel 5.6中。 一切都可以在文档中找到: https : //laravel.com/docs/5.6/testing
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.