Skip to content

Commit 26563fa

Browse files
committed
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
1 parent 96e7a5e commit 26563fa

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tests/Commands/User/CheckUserEmailExistTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44

55
use App\Services\WikiUserEmailChecker;
66
use App\User;
7+
use Illuminate\Foundation\Testing\DatabaseTransactions;
78
use Mockery;
89
use Tests\TestCase;
910

1011
class CheckUserEmailExistTest extends TestCase {
11-
protected function tearDown(): void {
12-
// delete all users
13-
User::query()->delete();
14-
}
12+
use DatabaseTransactions;
1513

1614
public function testItFindsEmailInApiUsersTable() {
1715
User::factory()->create([

0 commit comments

Comments
 (0)