diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 8364a84..f6ca22a 100755 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -2,18 +2,29 @@ namespace Tests\Feature; -// use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class ExampleTest extends TestCase { + use RefreshDatabase; + /** - * A basic test example. + * The home page must render for an anonymous visitor on an empty database. + * + * Previously 500'd because this test skipped RefreshDatabase, so the + * home controller tried to query a `videos` table that didn't exist in + * the in-memory testing DB. */ public function test_the_application_returns_a_successful_response(): void { - $response = $this->get('/'); + // phpunit.xml + .env.testing + TestCase::assertSafeTestDatabase() point + // this at :memory: — matching the trio every Phase test uses. + putenv('DB_CONNECTION=sqlite'); + putenv('DB_DATABASE=:memory:'); + $_ENV['DB_CONNECTION'] = 'sqlite'; + $_ENV['DB_DATABASE'] = ':memory:'; - $response->assertStatus(200); + $this->get('/')->assertStatus(200); } }