- Extract business logic from controllers into Action classes: Post/, Workspace/, Hashtag/, Label/, Invite/, ApiKey/ - Create subdomain routing: app.trypost.test (Inertia dashboard), api.trypost.test (REST API with token auth) - Add ApiToken model with tp_ prefix, token_lookup/hash auth - Add AuthenticateApiToken middleware for API authentication - Create Api controllers with JSON Resources for all entities - Create App controllers that use Actions + Inertia responses - Organize Form Requests into Api/ and App/ directories - Add api_tokens migration - Update all route names with app. prefix - Update all tests to use new route names (684 passing)
49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Mail\WorkspaceInvite;
|
|
use App\Models\Workspace;
|
|
use App\Models\WorkspaceInvite as WorkspaceInviteModel;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
test('workspace invite mail has correct subject', function () {
|
|
$workspace = Workspace::factory()->create(['name' => 'Test Workspace']);
|
|
$invite = WorkspaceInviteModel::factory()->create([
|
|
'workspace_id' => $workspace->id,
|
|
]);
|
|
|
|
$mail = new WorkspaceInvite($invite);
|
|
|
|
expect($mail->envelope()->subject)->toBe("You've been invited to join Test Workspace");
|
|
});
|
|
|
|
test('workspace invite mail has correct content', function () {
|
|
$workspace = Workspace::factory()->create(['name' => 'My Team']);
|
|
$invite = WorkspaceInviteModel::factory()->create([
|
|
'workspace_id' => $workspace->id,
|
|
]);
|
|
|
|
$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");
|
|
expect($content->with['previewText'])->toBe("You've been invited to join My Team");
|
|
expect($content->with['invite'])->toBe($invite);
|
|
expect($content->with['url'])->toBe(route('app.invites.show', $invite->id));
|
|
});
|
|
|
|
test('workspace invite mail has no attachments', function () {
|
|
$invite = WorkspaceInviteModel::factory()->create();
|
|
|
|
$mail = new WorkspaceInvite($invite);
|
|
|
|
expect($mail->attachments())->toBeEmpty();
|
|
});
|
|
|
|
test('workspace invite mail is queueable', function () {
|
|
$invite = WorkspaceInviteModel::factory()->create();
|
|
|
|
$mail = new WorkspaceInvite($invite);
|
|
|
|
expect($mail)->toBeInstanceOf(ShouldQueue::class);
|
|
});
|