Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/Mail/SignupInvitationTest.php
<?php | <?php | ||||
namespace Tests\Unit\Mail; | namespace Tests\Unit\Mail; | ||||
use App\Mail\SignupInvitation; | use App\Mail\SignupInvitation; | ||||
use App\SignupInvitation as SI; | use App\SignupInvitation as SI; | ||||
use App\Utils; | use App\Utils; | ||||
use Tests\MailInterceptTrait; | |||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class SignupInvitationTest extends TestCase | class SignupInvitationTest extends TestCase | ||||
{ | { | ||||
use MailInterceptTrait; | |||||
/** | /** | ||||
* Test email content | * Test email content | ||||
*/ | */ | ||||
public function testBuild(): void | public function testBuild(): void | ||||
{ | { | ||||
$invitation = new SI([ | $invitation = new SI([ | ||||
'id' => 'abc', | 'id' => 'abc', | ||||
'email' => 'test@email', | 'email' => 'test@email', | ||||
]); | ]); | ||||
$mail = $this->fakeMail(new SignupInvitation($invitation)); | $mail = $this->renderMail(new SignupInvitation($invitation)); | ||||
$html = $mail['html']; | $html = $mail['html']; | ||||
$plain = $mail['plain']; | $plain = $mail['plain']; | ||||
$url = Utils::serviceUrl('/signup/invite/' . $invitation->id); | $url = Utils::serviceUrl('/signup/invite/' . $invitation->id); | ||||
$link = "<a href=\"$url\">$url</a>"; | $link = "<a href=\"$url\">$url</a>"; | ||||
$appName = \config('app.name'); | $appName = \config('app.name'); | ||||
$this->assertMailSubject("$appName Invitation", $mail['message']); | $this->assertSame("$appName Invitation", $mail['subject']); | ||||
$this->assertStringStartsWith('<!DOCTYPE html>', $html); | $this->assertStringStartsWith('<!DOCTYPE html>', $html); | ||||
$this->assertTrue(strpos($html, $link) > 0); | $this->assertTrue(strpos($html, $link) > 0); | ||||
$this->assertTrue(strpos($html, "invited to join $appName") > 0); | $this->assertTrue(strpos($html, "invited to join $appName") > 0); | ||||
$this->assertStringStartsWith("Hi,", $plain); | $this->assertStringStartsWith("Hi,", $plain); | ||||
$this->assertTrue(strpos($plain, "invited to join $appName") > 0); | $this->assertTrue(strpos($plain, "invited to join $appName") > 0); | ||||
$this->assertTrue(strpos($plain, $url) > 0); | $this->assertTrue(strpos($plain, $url) > 0); | ||||
} | } | ||||
} | } |