Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/Mail/PaymentFailureTest.php
<?php | <?php | ||||
namespace Tests\Unit\Mail; | namespace Tests\Unit\Mail; | ||||
use App\Mail\PaymentFailure; | use App\Mail\PaymentFailure; | ||||
use App\Payment; | use App\Payment; | ||||
use App\User; | use App\User; | ||||
use Tests\MailInterceptTrait; | |||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class PaymentFailureTest extends TestCase | class PaymentFailureTest extends TestCase | ||||
{ | { | ||||
use MailInterceptTrait; | |||||
/** | /** | ||||
* Test email content | * Test email content | ||||
*/ | */ | ||||
public function testBuild(): void | public function testBuild(): void | ||||
{ | { | ||||
$user = new User(); | $user = new User(); | ||||
$payment = new Payment(); | $payment = new Payment(); | ||||
$payment->amount = 123; | $payment->amount = 123; | ||||
\config(['app.support_url' => 'https://kolab.org/support']); | \config(['app.support_url' => 'https://kolab.org/support']); | ||||
$mail = $this->fakeMail(new PaymentFailure($payment, $user)); | $mail = $this->renderMail(new PaymentFailure($payment, $user)); | ||||
$html = $mail['html']; | $html = $mail['html']; | ||||
$plain = $mail['plain']; | $plain = $mail['plain']; | ||||
$walletUrl = \App\Utils::serviceUrl('/wallet'); | $walletUrl = \App\Utils::serviceUrl('/wallet'); | ||||
$walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl); | $walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl); | ||||
$supportUrl = \config('app.support_url'); | $supportUrl = \config('app.support_url'); | ||||
$supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl); | $supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl); | ||||
$appName = \config('app.name'); | $appName = \config('app.name'); | ||||
$this->assertMailSubject("$appName Payment Failed", $mail['message']); | $this->assertSame("$appName Payment Failed", $mail['subject']); | ||||
$this->assertStringStartsWith('<!DOCTYPE html>', $html); | $this->assertStringStartsWith('<!DOCTYPE html>', $html); | ||||
$this->assertTrue(strpos($html, $user->name(true)) > 0); | $this->assertTrue(strpos($html, $user->name(true)) > 0); | ||||
$this->assertTrue(strpos($html, $walletLink) > 0); | $this->assertTrue(strpos($html, $walletLink) > 0); | ||||
$this->assertTrue(strpos($html, $supportLink) > 0); | $this->assertTrue(strpos($html, $supportLink) > 0); | ||||
$this->assertTrue(strpos($html, "$appName Support") > 0); | $this->assertTrue(strpos($html, "$appName Support") > 0); | ||||
$this->assertTrue(strpos($html, "Something went wrong with auto-payment for your $appName account") > 0); | $this->assertTrue(strpos($html, "Something went wrong with auto-payment for your $appName account") > 0); | ||||
$this->assertTrue(strpos($html, "$appName Team") > 0); | $this->assertTrue(strpos($html, "$appName Team") > 0); | ||||
Show All 9 Lines |