mercredi 22 janvier 2020

How to test class with Config facade inside?

One of my classes uses the Config.get inside its constructor. When I write a unit test I want to set some Config variables.

class SomeTest extends TestCase
{
    protected function setUp():void
    {
        parent::setUp();
        $locale = 'zz';
        Config::set("app.locale", $locale);
   }
   ...
}

And get the error:

 RuntimeException: A facade root has not been set.

How to test classes that use Config facade?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire