Skip to content

A free open source IT asset/license management system

Add failing test

Marcus Moore2e67787d753c
diff --git a/tests/Feature/Notifications/Email/EmailNotificationsToUserUponCheckoutTest.php b/tests/Feature/Notifications/Email/EmailNotificationsToUserUponCheckoutTest.php
index 4a6d3b0b8b..9efe1dc251 100644
--- a/tests/Feature/Notifications/Email/EmailNotificationsToUserUponCheckoutTest.php
+++ b/tests/Feature/Notifications/Email/EmailNotificationsToUserUponCheckoutTest.php
@@ -7,6 +7,7 @@ use App\Mail\CheckoutAssetMail;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
+use App\Models\CheckoutAcceptance;
use App\Models\User;
use Illuminate\Support\Facades\Mail;
use PHPUnit\Framework\Attributes\Group;
@@ -51,6 +52,31 @@ class EmailNotificationsToUserUponCheckoutTest extends TestCase
$this->assertUserSentEmail();
}
+ public function test_email_contains_link_to_confirm_acceptance_when_category_requires_acceptance()
+ {
+ $this->category->update(['require_acceptance' => true]);
+
+ $this->fireCheckoutEvent();
+
+ Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) {
+ $acceptance = CheckoutAcceptance::query()
+ ->forUser($this->user)
+ ->whereCheckoutableId($this->asset->id)
+ ->whereCheckoutableType(Asset::class)
+ ->firstOrFail();
+
+ $url = route('account.accept.item', $acceptance);
+
+ $mailContents = $mail->render();
+
+ if (! str_contains($mailContents, $url)) {
+ $this->fail('Email does not contain the acceptance url');
+ }
+
+ return $mail->hasTo($this->user->email);
+ });
+ }
+
public function test_email_sent_to_user_when_category_using_default_eula()
{
$this->settings->setEula();