trypost/tests/Unit/Mail/WorkspaceInviteTest.php

52 lines
1.5 KiB
PHP
Raw Normal View History

2026-01-19 00:49:13 +00:00
<?php
declare(strict_types=1);
2026-01-19 00:49:13 +00:00
use App\Mail\WorkspaceInvite;
use App\Models\Account;
use App\Models\Invite;
use Illuminate\Contracts\Queue\ShouldQueue;
2026-01-19 00:49:13 +00:00
test('workspace invite mail has correct subject', function () {
$account = Account::factory()->create(['name' => 'Test Account']);
$invite = Invite::factory()->create([
'account_id' => $account->id,
2026-01-19 00:49:13 +00:00
]);
$mail = new WorkspaceInvite($invite);
expect($mail->envelope()->subject)->toBe("You've been invited to join Test Account");
2026-01-19 00:49:13 +00:00
});
test('workspace invite mail has correct content', function () {
$account = Account::factory()->create(['name' => 'My Team']);
$invite = Invite::factory()->create([
'account_id' => $account->id,
2026-01-19 00:49:13 +00:00
]);
$mail = new WorkspaceInvite($invite);
$content = $mail->content();
expect($content->view)->toBe('mail.workspace-invite');
expect($content->with['title'])->toBe("You've been invited to join My Team");
2026-01-20 19:53:54 +00:00
expect($content->with['previewText'])->toBe("You've been invited to join My Team");
2026-01-19 00:49:13 +00:00
expect($content->with['invite'])->toBe($invite);
expect($content->with['url'])->toBe(route('app.invites.show', $invite->id));
2026-01-19 00:49:13 +00:00
});
test('workspace invite mail has no attachments', function () {
$invite = Invite::factory()->create();
2026-01-19 00:49:13 +00:00
$mail = new WorkspaceInvite($invite);
expect($mail->attachments())->toBeEmpty();
});
test('workspace invite mail is queueable', function () {
$invite = Invite::factory()->create();
2026-01-19 00:49:13 +00:00
$mail = new WorkspaceInvite($invite);
expect($mail)->toBeInstanceOf(ShouldQueue::class);
2026-01-19 00:49:13 +00:00
});