mercredi 10 août 2022

How to Mock environment in Laravel 5.7

I'm trying to implement a unit test in Laravel 5.7 I want to mock APP_ENV testing to production or any else as I want.

Unit test code:

App::shouldReceive('environment')->with('APP_ENV')->once()->andReturn('production');

Code:

if (in_array(env('APP_ENV'), ["production", 'local'])) {
    return "This production environment";
}

There was 1 error:

Mockery\Exception\BadMethodCallException: Received Mockery_5_Illuminate_Foundation_Application::offsetGet(), but no expectations were specified


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire