forked from laravel/jetstream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InviteTeamMemberTest.php
33 lines (23 loc) · 967 Bytes
/
InviteTeamMemberTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
use App\Models\User;
use Illuminate\Support\Facades\Mail;
use Laravel\Jetstream\Mail\TeamInvitation;
test('team members can be invited to team', function () {
Mail::fake();
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$response = $this->post('/teams/'.$user->currentTeam->id.'/members', [
'email' => '[email protected]',
'role' => 'admin',
]);
Mail::assertSent(TeamInvitation::class);
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(1);
});
test('team member invitations can be cancelled', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
$invitation = $user->currentTeam->teamInvitations()->create([
'email' => '[email protected]',
'role' => 'admin',
]);
$response = $this->delete('/team-invitations/'.$invitation->id);
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
});