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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -