Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/Mail/PasswordResetTest.php
Show All 16 Lines | class PasswordResetTest extends TestCase | ||||
public function testPasswordResetBuild() | public function testPasswordResetBuild() | ||||
{ | { | ||||
$code = new VerificationCode([ | $code = new VerificationCode([ | ||||
'user_id' => 123456789, | 'user_id' => 123456789, | ||||
'mode' => 'password-reset', | 'mode' => 'password-reset', | ||||
'code' => 'code', | 'code' => 'code', | ||||
'short_code' => 'short-code', | 'short_code' => 'short-code', | ||||
]); | ]); | ||||
// @phpstan-ignore-next-line | |||||
$code->user = new User([ | $code->user = new User([ | ||||
'name' => 'User Name', | 'name' => 'User Name', | ||||
]); | ]); | ||||
$mail = new PasswordReset($code); | $mail = new PasswordReset($code); | ||||
$html = $mail->build()->render(); | $html = $mail->build()->render(); | ||||
$url = \config('app.url') . '/login/reset/' . $code->short_code . '-' . $code->code; | $url = \config('app.url') . '/login/reset/' . $code->short_code . '-' . $code->code; | ||||
$link = "<a href=\"$url\">$url</a>"; | $link = "<a href=\"$url\">$url</a>"; | ||||
$this->assertSame(\config('app.name') . ' Password Reset', $mail->subject); | $this->assertSame(\config('app.name') . ' Password Reset', $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, $code->user->name(true)) > 0); | $this->assertTrue(strpos($html, $code->user->name(true)) > 0); | ||||
} | } | ||||
} | } |