Skip to content

Commit

Permalink
Test InvitedToSpace mail
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Dec 29, 2023
1 parent abac945 commit bf7b37b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
9 changes: 4 additions & 5 deletions app/Mail/InvitedToSpace.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ class InvitedToSpace extends Mailable
use Queueable;
use SerializesModels;

protected $invite;

public function __construct(SpaceInvite $invite)
{
$this->invite = $invite;
public function __construct(
protected SpaceInvite $invite,
) {
//
}

public function build()
Expand Down
2 changes: 1 addition & 1 deletion resources/views/emails/invited_to_space_plain.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ $invite->inviter->name }} has invited you to "{{ $invite->space->name }}"
{{ $invite->inviter->name }} has invited you to "{{ $invite->space->name }}".

Use the link below to check out your invite.

Expand Down
37 changes: 37 additions & 0 deletions tests/Unit/Mail/InvitedToSpaceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Tests\Unit\Mail;

use App\Mail\InvitedToSpace;
use App\Models\Space;
use App\Models\SpaceInvite;
use App\Models\User;
use Tests\TestCase;

class InvitedToSpaceTest extends TestCase
{
public function testMailable(): void
{
$space = Space::factory()
->create([
'name' => 'Foo Bar',
]);

$inviterUser = User::factory()
->create([
'name' => 'John Doe',
]);

$spaceInvite = SpaceInvite::factory()
->create([
'space_id' => $space->id,
'inviter_user_id' => $inviterUser->id,
]);

$mailable = new InvitedToSpace($spaceInvite);

$mailable
->assertSeeInText('John Doe has invited you to "Foo Bar".')
->assertSeeInHtml('<a href="' . config('app.url') . '/spaces/' . $space->id . '/invites/' . $spaceInvite->id . '">Check out your invite</a>', false); // phpcs:ignore
}
}

0 comments on commit bf7b37b

Please sign in to comment.