To make artisan migrate a fresh database before running tests, use DatabaseMigrations
. Also if you want to avoid middleware like Auth, use WithoutMiddleware
.
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ExampleTest extends TestCase
{
use DatabaseMigrations, WithoutMiddleware;
/**
* A basic functional test example.
*
* @return void
*/
public function testExampleIndex()
{
$this->visit('/protected-page')
->see('All good');
}
}