I have an application and I want to use Laravel Dusk.
I created a file named .env.dusk.local with a database for tests and a file named .env with my default database.
I ran the php artisan command and created the user /register .
After I created a login test with the same email address but with a different password, this will not be a problem, because in .env.dusk.local it will be a different bank and will not be registered with anyone.
But when I run the php artisan dusk command, it takes information from the original .env and finishes erasing all entries from my default database.
I would like to know how to download information from my .env.dusk.local and use a test database.
.env default
APP_ENV=local APP_KEY=base64:K8otIkxJk0rFsZYSEq1hwBuaxQX3QI3Bb7ZmemJRIWg= APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost:8000 DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_dusk DB_USERNAME=root DB_PASSWORD=123456
.env.dusk.local
APP_ENV=local APP_KEY=base64:K8otIkxJk0rFsZYSEq1hwBuaxQX3QI3Bb7ZmemJRIWg= APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost:8000 DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_dusk_test DB_USERNAME=root DB_PASSWORD=123456
Mu function for testLogin
namespace Tests\Browser; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Support\Facades\App; use Tests\DuskTestCase; class LoginTest extends DuskTestCase { use DatabaseMigrations; public function testLogin() { $user = factory(\App\User::class)->create(['email' => ' lucas@example.com ']); $this->browse(function ($browser) use ($user) { $browser->visit('/login') ->type('email', $user->email) ->type('password', 'secret') ->press('Login') ->assertPathIs('/home'); }); } }
Here is this project on github
source share