Level 67
if (App::runningUnitTests())
https://laravel.com/api/6.x/Illuminate/Contracts/Foundation/Application.html#method_runningUnitTests
if (config('app.env') == 'testing')
if (App::environment() == 'testing')
should work too
17 likes
Hi, when laravel run tests, both unit test and feature tests, does is sets any global variables, that I can detect other places in the application?
I'm not interested in the .env trick. But would like to know if there are other ways to detect, that the application is in test mode?
Currently I think of setting a global variable in my test.. but maybe there is already something?
It's in my controller, that I would like to detect, that a test is running! ? :-)
Thanks
Please or to participate in this conversation.