Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/Mail/PasswordResetTest.php
<?php | <?php | ||||
namespace Tests\Unit\Mail; | namespace Tests\Unit\Mail; | ||||
use App\Mail\PasswordReset; | use App\Mail\PasswordReset; | ||||
use App\User; | use App\User; | ||||
use App\Utils; | |||||
use App\VerificationCode; | use App\VerificationCode; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class PasswordResetTest extends TestCase | class PasswordResetTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* Test email content | * Test email content | ||||
* | * | ||||
Show All 11 Lines | public function testPasswordResetBuild() | ||||
// @phpstan-ignore-next-line | // @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 = Utils::serviceUrl('/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); | ||||
} | } | ||||
} | } |