How to test Laravel 5 jobs?(如何测试 Laravel 5 作业?)
问题描述
当工作完成时,我尝试捕捉一个事件
I try to catch an event, when job is completed
测试代码:
UserController中的方法:
我的工作:
作业完成后我需要检查一些数据,但我从$event->job->payload()
in Queue::after
而且我不明白如何检查作业?
I need to check some data after job is complete but I get serialized data from
$event->job->payload()
in Queue::after
And I don't understand how to check job ?
推荐答案
好吧,要测试 handle
方法中的逻辑,你只需要实例化作业类 &调用 handle
方法.
Well, to test the logic inside handle
method you just need to instantiate the job class & invoke the handle
method.
记住,工作毕竟只是一门课.
Remember, a job is just a class after all.
这篇关于如何测试 Laravel 5 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!