php - No output and not worked When I run [Artisan::call(...)] or [shell_exec(...)] in phpunit test, but when not in phpunit, it is ok
Get the solution ↓↓↓/**
* @test
*/
public function xxx()
{
$exitCode = Artisan::call('queue:work');
//shell_exec('php artisan queue:work');
}
RunArtisan::call(...)
orshell_exec(...)
in PHPUnit test, it is not working.
Answer
Solution:
For your unit tests you don't use your normal laravel queue like you do in the rest of your project.
Start your queue using and then apply your test logic.
Your tests will push events in this queue and the mock workers will pick up.
Read more about mocking methods here.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: php_network_getaddresses: getaddrinfo failed: temporary failure in name resolution
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.