繁体   English   中英

如何在不使用浏览器的情况下在PHP(Laravel 5.6)中运行函数的情况下检查其是否运行良好

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM