laravel - Lumen testing environment with MongoDB -
in service provider set mongo database name using within application this:
$this->app->bind('mongodb', function() { $client = new mongoclient(); return $client->selectdb('myproductiondatabase'); });
when running phpunit run tests want use different database gets recreated on every test. ive done far is:
$db = $this->app->environment('production') ? 'myproductiondatabase' : 'mytestingdatabase'; $this->app->bind('mongodb', function() { $client = new mongoclient(); return $client->selectdb($db); });
this doesn't seem quite right. understand can make multiple .env files testing , such. not sure how when running phpunit cmd line know .env file load.
whats best way?
Comments
Post a Comment