0

I'm trying to test my applications ability to handle missing configuration.

How do I mock calls to env()?

I can't find any documentation in Mockery for mocking global function calls...

AlexW
  • 134
  • 1
  • 9
  • 1
    What `env()` variable are you trying to test? Most `.env` variables are converted to a `config()` option, like `config('app.env')` would be equivalent to `env('APP_ENV')`. Additionally, `config()` allows on the fly setting, so an approach like `config(['app.env' => null])` (to remove the setting), followed by `Assert::assertNull(config('app.env'))` (or whatever the syntax is you're using for tests) to assert that the `env` setting (via `config()`) is in fact missing. – Tim Lewis Oct 27 '20 at 17:30
  • Tim's suggestion is the way I've gone, but thank your Alex for another useful approach. – AlexW Nov 02 '20 at 16:19

0 Answers0