mardi 30 juin 2015

Set SQLite as database for unit testing in Laravel 5.1

I'm trying to set-up unit testing in Laravel 5.1. Following the documentation I see this:

Laravel is built with testing in mind. In fact, support for testing with PHPUnit is included out of the box

and

When running tests, Laravel will automatically set the configuration environment to testing. Laravel automatically configures the session and cache to the array driver while testing, meaning no session or cache data will be persisted while testing.

which is awesome. But... how do I tell Laravel to use SQLite database connection when tests are ran?

Only thing there is in config/database.php is this commented code:

/* We might use this connection for unit tests
'sqlite' => [
    'driver'   => 'sqlite',
    'database' => storage_path().'/database.sqlite',
    'prefix'   => '',
],
*/

We might use this :)

Is there a way to set this globally for all test? Do I need to set the connecton in every test case?

Any help appreciated.

Aucun commentaire:

Enregistrer un commentaire