dimanche 22 septembre 2019

Laravel 5.8 & PHPUnit - wrong environment

I have some problem with Laravel 5.8.35 and PHPUnit 8.3.4. After installing Laravel Telescope my tests stops working because:

ReflectionException : Class env does not exist

In AppServiceProvider I have condition:

if ($this->app->isLocal()) {
  $this->app->register(TelescopeServiceProvider::class);
}

so Telescope should runs only for local environment.

Then I added:

<env name="APP_ENV" value="testing" force="true"/>

to phpunit.xml to force valid environment for testing to disable loading of TelescopeServiceProvider. But this not works, $this->app->environment() still returns local (from .env). Other env variables from phpunit (like DB_CONNECTION) are read correctly.

What did I miss?

Aucun commentaire:

Enregistrer un commentaire