mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-13 06:56:48 +00:00
Laravel Jetstream install
This commit is contained in:
63
tests/Feature/InviteTeamMemberTest.php
Normal file
63
tests/Feature/InviteTeamMemberTest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Laravel\Jetstream\Features;
|
||||
use Laravel\Jetstream\Http\Livewire\TeamMemberManager;
|
||||
use Laravel\Jetstream\Mail\TeamInvitation;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InviteTeamMemberTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_team_members_can_be_invited_to_team()
|
||||
{
|
||||
if (! Features::sendsTeamInvitations()) {
|
||||
return $this->markTestSkipped('Team invitations not enabled.');
|
||||
}
|
||||
|
||||
Mail::fake();
|
||||
|
||||
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
|
||||
|
||||
$component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
|
||||
->set('addTeamMemberForm', [
|
||||
'email' => 'test@example.com',
|
||||
'role' => 'admin',
|
||||
])->call('addTeamMember');
|
||||
|
||||
Mail::assertSent(TeamInvitation::class);
|
||||
|
||||
$this->assertCount(1, $user->currentTeam->fresh()->teamInvitations);
|
||||
}
|
||||
|
||||
public function test_team_member_invitations_can_be_cancelled()
|
||||
{
|
||||
if (! Features::sendsTeamInvitations()) {
|
||||
return $this->markTestSkipped('Team invitations not enabled.');
|
||||
}
|
||||
|
||||
Mail::fake();
|
||||
|
||||
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
|
||||
|
||||
// Add the team member...
|
||||
$component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
|
||||
->set('addTeamMemberForm', [
|
||||
'email' => 'test@example.com',
|
||||
'role' => 'admin',
|
||||
])->call('addTeamMember');
|
||||
|
||||
$invitationId = $user->currentTeam->fresh()->teamInvitations->first()->id;
|
||||
|
||||
// Cancel the team invitation...
|
||||
$component->call('cancelTeamInvitation', $invitationId);
|
||||
|
||||
$this->assertCount(0, $user->currentTeam->fresh()->teamInvitations);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user