Add extensive controller and model tests
This commit is contained in:
22
tests/Unit/RankModelTest.php
Normal file
22
tests/Unit/RankModelTest.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Rank;
|
||||
use App\Models\User;
|
||||
|
||||
it('relates ranks to users', function (): void {
|
||||
$rank = Rank::create([
|
||||
'name' => 'Gold',
|
||||
'badge_type' => 'text',
|
||||
'badge_text' => 'G',
|
||||
'color' => '#ffaa00',
|
||||
]);
|
||||
|
||||
$user = User::factory()->create([
|
||||
'rank_id' => $rank->id,
|
||||
]);
|
||||
|
||||
$rank->load('users');
|
||||
|
||||
expect($rank->users)->toHaveCount(1);
|
||||
expect($rank->users->first()->id)->toBe($user->id);
|
||||
});
|
||||
Reference in New Issue
Block a user