Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/Mail/NegativeBalanceTest.php
- This file was copied to src/tests/Unit/Mail/NegativeBalanceBeforeDeleteTest.php, src/tests/Unit/Mail/NegativeBalanceReminderTest.php, src/tests/Unit/Mail/NegativeBalanceSuspendedTest.php.
<?php | <?php | ||||
namespace Tests\Unit\Mail; | namespace Tests\Unit\Mail; | ||||
use App\Mail\NegativeBalance; | use App\Mail\NegativeBalance; | ||||
use App\User; | use App\User; | ||||
use App\Wallet; | |||||
use Tests\MailInterceptTrait; | use Tests\MailInterceptTrait; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class NegativeBalanceTest extends TestCase | class NegativeBalanceTest extends TestCase | ||||
{ | { | ||||
use MailInterceptTrait; | use MailInterceptTrait; | ||||
/** | /** | ||||
* Test email content | * Test email content | ||||
*/ | */ | ||||
public function testBuild(): void | public function testBuild(): void | ||||
{ | { | ||||
$user = new User(); | $user = new User(); | ||||
$wallet = new Wallet(); | |||||
\config([ | \config([ | ||||
'app.support_url' => 'https://kolab.org/support', | 'app.support_url' => 'https://kolab.org/support', | ||||
]); | ]); | ||||
$mail = $this->fakeMail(new NegativeBalance($user)); | $mail = $this->fakeMail(new NegativeBalance($wallet, $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 Reminder", $mail['message']); | $this->assertMailSubject("$appName Payment Required", $mail['message']); | ||||
$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, "behind on paying for your $appName account") > 0); | $this->assertTrue(strpos($html, "your $appName account balance has run into the nega") > 0); | ||||
$this->assertTrue(strpos($html, "$appName Support") > 0); | $this->assertTrue(strpos($html, "$appName Support") > 0); | ||||
$this->assertTrue(strpos($html, "$appName Team") > 0); | $this->assertTrue(strpos($html, "$appName Team") > 0); | ||||
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain); | $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); | ||||
$this->assertTrue(strpos($plain, $walletUrl) > 0); | $this->assertTrue(strpos($plain, $walletUrl) > 0); | ||||
$this->assertTrue(strpos($plain, $supportUrl) > 0); | $this->assertTrue(strpos($plain, $supportUrl) > 0); | ||||
$this->assertTrue(strpos($plain, "behind on paying for your $appName account") > 0); | $this->assertTrue(strpos($plain, "your $appName account balance has run into the nega") > 0); | ||||
$this->assertTrue(strpos($plain, "$appName Support") > 0); | $this->assertTrue(strpos($plain, "$appName Support") > 0); | ||||
$this->assertTrue(strpos($plain, "$appName Team") > 0); | $this->assertTrue(strpos($plain, "$appName Team") > 0); | ||||
} | } | ||||
} | } |