1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6declare(strict_types=1);
7
8namespace Tests\Models;
9
10use App\Models\Team;
11use App\Models\TeamMember;
12use App\Models\User;
13use Tests\TestCase;
14
15class TeamTest extends TestCase
16{
17 public function testDelete(): void
18 {
19 $team = Team::factory()->create();
20 $team->members()->create(['user_id' => User::factory()->create()->getKey()]);
21 $otherTeam = Team::factory()->create();
22 $otherTeam->members()->create(['user_id' => User::factory()->create()->getKey()]);
23
24 $this->expectCountChange(fn () => Team::count(), -1);
25 $this->expectCountChange(fn () => TeamMember::count(), -2);
26 $this->expectCountChange(fn () => $otherTeam->members()->count(), 0);
27
28 $team->fresh()->delete();
29
30 $this->assertNotNull($otherTeam->fresh());
31 }
32}