简体   繁体   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)

Here is an example function that i'm trying to run. 这是我尝试运行的示例函数。

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();
}

You should check out PHPUnit and testing. 您应该签出PHPUnit并进行测试。 Maybe use Mockery for mocking objects. 也许使用Mockery模拟对象。 It is already included by default in Laravel 5.6. 默认情况下,它已包含在Laravel 5.6中。 Everything can be found in the documentation: https://laravel.com/docs/5.6/testing 一切都可以在文档中找到: https : //laravel.com/docs/5.6/testing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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