From 26563fa79faee379cb23dc37a3a26fe09437cf60 Mon Sep 17 00:00:00 2001 From: Ollie Date: Tue, 27 Jan 2026 10:25:27 +0000 Subject: [PATCH] Platform API: Use DatabaseTransactions instead of deleting all users Cleaning up from tests with `User::query()->delete();` is a bad idea as it will delete all users rather than just the ones created in `CheckUserEmailExistTest`. Use Laravel's `DatabaseTransactions` trait instead that wraps each test case in a database transaction and only reverts database modifications cause by the test. Bug: T415636 --- tests/Commands/User/CheckUserEmailExistTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/Commands/User/CheckUserEmailExistTest.php b/tests/Commands/User/CheckUserEmailExistTest.php index 8d94da04..9ec58ee4 100644 --- a/tests/Commands/User/CheckUserEmailExistTest.php +++ b/tests/Commands/User/CheckUserEmailExistTest.php @@ -4,14 +4,12 @@ use App\Services\WikiUserEmailChecker; use App\User; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Mockery; use Tests\TestCase; class CheckUserEmailExistTest extends TestCase { - protected function tearDown(): void { - // delete all users - User::query()->delete(); - } + use DatabaseTransactions; public function testItFindsEmailInApiUsersTable() { User::factory()->create([