From 0e8bcfd47bc0f18e03907d7fddd608a2862b0fa8 Mon Sep 17 00:00:00 2001 From: ghassan Date: Wed, 21 Oct 2026 11:57:11 +0300 Subject: [PATCH] =?UTF-8?q?test:=20fix=20ExampleTest=20=E2=80=94=20add=20R?= =?UTF-8?q?efreshDatabase=20and=20point=20at=20:memory:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ExampleTest hit GET / expecting 200, but had no RefreshDatabase trait, so the home controller's Video::public()->pluck('id') query hit a non-existent `videos` table in the testing DB and 500'd. It's been failing since Phase 1 but was always flagged as "pre-existing, unrelated" because the test file isn't touched by any audit code. Now mirrors the Phase-test setup: putenv forces :memory: before parent::setUp, RefreshDatabase migrates the throwaway DB, and the assertion passes against an empty home feed. 46/46 green. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/Feature/ExampleTest.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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); } }