diff --git a/.travis.yml b/.travis.yml index b8a3031c..5adf965b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ env: before_script: - composer config discard-changes true - - touch laravel/database/database.sqlite + - php ./create-sqlite-db - if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi - if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable; fi - if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi diff --git a/README.md b/README.md index ae0a84c9..bbad5787 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,32 @@ class BrowserTestCase extends Orchestra\Testbench\Dusk\TestCase } ``` +### Database + +By default you can either use `sqlite`, `mysql`, `pgsql` or `sqlsrv` with Testbench Dusk, however do note that it is impossible to use `sqlite` using `:memory:` database as you would with **Testbench** or **Tesbench BrowserKit**. + +If you opt to use `sqlite`, you might want to set the default database connection to `sqlite` either using `phpunit` configuration or setting it up on `getEnvironmentSetUp()` method. + +```php +/** + * Define environment setup. + * + * @param Illuminate\Foundation\Application $app + * + * @return void + */ +protected function getEnvironmentSetUp($app) +{ + $this->app['config']->set('database.default', 'sqlite'); +} +``` + +To populate the database you just need to run the following code: + +```bash +php vendor/orchestra/testbench-dusk/create-sqlite-db +``` + ## Advanced Usage ### Customising the Laravel App instance used during a test diff --git a/composer.json b/composer.json index c6f9c743..97787578 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ }, "scripts": { "test": [ + "@php create-sqlite-db", "@php vendor/bin/phpunit -c ./ --color" ] }, diff --git a/create-sqlite-db b/create-sqlite-db new file mode 100755 index 00000000..3f8a781a --- /dev/null +++ b/create-sqlite-db @@ -0,0 +1,8 @@ +#!/usr/bin/env php +createDatabase(config('database.default')); - $this->withFactories(__DIR__.'/../factories'); $this->loadLaravelMigrations(config('database.default')); } diff --git a/tests/Browser/RouteTest.php b/tests/Browser/RouteTest.php index e18c0de0..21be97ed 100644 --- a/tests/Browser/RouteTest.php +++ b/tests/Browser/RouteTest.php @@ -10,7 +10,7 @@ class RouteTest extends TestCase /** * Define environment setup. * - * @param Illuminate\Foundation\Application $app + * @param Illuminate\Foundation\Application $app * * @return void */