diff --git a/src/tests/Unit/Mail/NegativeBalanceBeforeDeleteTest.php b/src/tests/Unit/Mail/NegativeBalanceBeforeDeleteTest.php index 7f601a20..1e5d11e5 100644 --- a/src/tests/Unit/Mail/NegativeBalanceBeforeDeleteTest.php +++ b/src/tests/Unit/Mail/NegativeBalanceBeforeDeleteTest.php @@ -1,125 +1,125 @@ getTestUser('ned@kolab.org'); $wallet = $user->wallets->first(); $wallet->balance = -100; $wallet->save(); $threshold = WalletCheck::threshold($wallet, WalletCheck::THRESHOLD_DELETE); \config([ 'app.support_url' => 'https://kolab.org/support', ]); $mail = $this->fakeMail(new NegativeBalanceBeforeDelete($wallet, $user)); $html = $mail['html']; $plain = $mail['plain']; $walletUrl = \App\Utils::serviceUrl('/wallet'); $walletLink = sprintf('%s', $walletUrl, $walletUrl); $supportUrl = \config('app.support_url'); $supportLink = sprintf('%s', $supportUrl, $supportUrl); - $appName = \config('app.name'); + $appName = $user->tenant->title; $this->assertMailSubject("$appName Final Warning", $mail['message']); $this->assertStringStartsWith('', $html); $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); $this->assertTrue(strpos($html, "This is a final reminder to settle your $appName") > 0); $this->assertTrue(strpos($html, $threshold->toDateString()) > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); $this->assertTrue(strpos($plain, "This is a final reminder to settle your $appName") > 0); $this->assertTrue(strpos($plain, $threshold->toDateString()) > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); // Test with user that is not the same tenant as in .env $user = $this->getTestUser('user@sample-tenant.dev-local'); $tenant = $user->tenant; $wallet = $user->wallets->first(); $wallet->balance = -100; $wallet->save(); $threshold = WalletCheck::threshold($wallet, WalletCheck::THRESHOLD_DELETE); $tenant->setSettings([ 'app.support_url' => 'https://test.org/support', 'app.public_url' => 'https://test.org', ]); $mail = $this->fakeMail(new NegativeBalanceBeforeDelete($wallet, $user)); $html = $mail['html']; $plain = $mail['plain']; $walletUrl = 'https://test.org/wallet'; $walletLink = sprintf('%s', $walletUrl, $walletUrl); $supportUrl = 'https://test.org/support'; $supportLink = sprintf('%s', $supportUrl, $supportUrl); $this->assertMailSubject("{$tenant->title} Final Warning", $mail['message']); $this->assertStringStartsWith('', $html); $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); $this->assertTrue(strpos($html, "This is a final reminder to settle your {$tenant->title}") > 0); $this->assertTrue(strpos($html, $threshold->toDateString()) > 0); $this->assertTrue(strpos($html, "{$tenant->title} Support") > 0); $this->assertTrue(strpos($html, "{$tenant->title} Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); $this->assertTrue(strpos($plain, "This is a final reminder to settle your {$tenant->title}") > 0); $this->assertTrue(strpos($plain, $threshold->toDateString()) > 0); $this->assertTrue(strpos($plain, "{$tenant->title} Support") > 0); $this->assertTrue(strpos($plain, "{$tenant->title} Team") > 0); } } diff --git a/src/tests/Unit/Mail/NegativeBalanceReminderTest.php b/src/tests/Unit/Mail/NegativeBalanceReminderTest.php index 53755cbc..f68d58b5 100644 --- a/src/tests/Unit/Mail/NegativeBalanceReminderTest.php +++ b/src/tests/Unit/Mail/NegativeBalanceReminderTest.php @@ -1,62 +1,62 @@ getTestUser('ned@kolab.org'); $wallet = $user->wallets->first(); $wallet->balance = -100; $wallet->save(); $threshold = WalletCheck::threshold($wallet, WalletCheck::THRESHOLD_SUSPEND); \config([ 'app.support_url' => 'https://kolab.org/support', ]); $mail = $this->fakeMail(new NegativeBalanceReminder($wallet, $user)); $html = $mail['html']; $plain = $mail['plain']; $walletUrl = \App\Utils::serviceUrl('/wallet'); $walletLink = sprintf('%s', $walletUrl, $walletUrl); $supportUrl = \config('app.support_url'); $supportLink = sprintf('%s', $supportUrl, $supportUrl); - $appName = \config('app.name'); + $appName = $user->tenant->title; $this->assertMailSubject("$appName Payment Reminder", $mail['message']); $this->assertStringStartsWith('', $html); $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); $this->assertTrue(strpos($html, "you are behind on paying for your $appName account") > 0); $this->assertTrue(strpos($html, $threshold->toDateString()) > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); $this->assertTrue(strpos($plain, "you are behind on paying for your $appName account") > 0); $this->assertTrue(strpos($plain, $threshold->toDateString()) > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } } diff --git a/src/tests/Unit/Mail/NegativeBalanceSuspendedTest.php b/src/tests/Unit/Mail/NegativeBalanceSuspendedTest.php index 7190ffab..fc59ad50 100644 --- a/src/tests/Unit/Mail/NegativeBalanceSuspendedTest.php +++ b/src/tests/Unit/Mail/NegativeBalanceSuspendedTest.php @@ -1,62 +1,62 @@ getTestUser('ned@kolab.org'); $wallet = $user->wallets->first(); $wallet->balance = -100; $wallet->save(); $threshold = WalletCheck::threshold($wallet, WalletCheck::THRESHOLD_DELETE); \config([ 'app.support_url' => 'https://kolab.org/support', ]); $mail = $this->fakeMail(new NegativeBalanceSuspended($wallet, $user)); $html = $mail['html']; $plain = $mail['plain']; $walletUrl = \App\Utils::serviceUrl('/wallet'); $walletLink = sprintf('%s', $walletUrl, $walletUrl); $supportUrl = \config('app.support_url'); $supportLink = sprintf('%s', $supportUrl, $supportUrl); - $appName = \config('app.name'); + $appName = $user->tenant->title; $this->assertMailSubject("$appName Account Suspended", $mail['message']); $this->assertStringStartsWith('', $html); $this->assertTrue(strpos($html, $user->name(true)) > 0); $this->assertTrue(strpos($html, $walletLink) > 0); $this->assertTrue(strpos($html, $supportLink) > 0); $this->assertTrue(strpos($html, "Your $appName account has been suspended") > 0); $this->assertTrue(strpos($html, $threshold->toDateString()) > 0); $this->assertTrue(strpos($html, "$appName Support") > 0); $this->assertTrue(strpos($html, "$appName Team") > 0); $this->assertStringStartsWith('Dear ' . $user->name(true), $plain); $this->assertTrue(strpos($plain, $walletUrl) > 0); $this->assertTrue(strpos($plain, $supportUrl) > 0); $this->assertTrue(strpos($plain, "Your $appName account has been suspended") > 0); $this->assertTrue(strpos($plain, $threshold->toDateString()) > 0); $this->assertTrue(strpos($plain, "$appName Support") > 0); $this->assertTrue(strpos($plain, "$appName Team") > 0); } }