Skip to content

A free open source IT asset/license management system

Improve readability

Marcus Moore2d0874920711
diff --git a/database/factories/CheckoutAcceptanceFactory.php b/database/factories/CheckoutAcceptanceFactory.php
index a15e942a84..bb56ab2b4a 100644
--- a/database/factories/CheckoutAcceptanceFactory.php
+++ b/database/factories/CheckoutAcceptanceFactory.php
@@ -64,6 +64,24 @@ class CheckoutAcceptanceFactory extends Factory
]);
}
+ public function withoutAlerting()
+ {
+ return $this->state(function () {
+ return [
+ 'alert_on_response_id' => null,
+ ];
+ });
+ }
+
+ public function withAlertingTo(User $user)
+ {
+ return $this->state(function () use ($user) {
+ return [
+ 'alert_on_response_id' => $user->id,
+ ];
+ });
+ }
+
private function createdAssociatedActionLogEntry(CheckoutAcceptance $acceptance): void
{
$acceptance->checkoutable->assetlog()->create([
diff --git a/tests/Feature/Notifications/Email/CheckoutResponseEmailTest.php b/tests/Feature/Notifications/Email/CheckoutResponseEmailTest.php
index 73dcd2cfb5..a761b77ce1 100644
--- a/tests/Feature/Notifications/Email/CheckoutResponseEmailTest.php
+++ b/tests/Feature/Notifications/Email/CheckoutResponseEmailTest.php
@@ -23,9 +23,8 @@ class CheckoutResponseEmailTest extends TestCase
$checkoutAcceptance = CheckoutAcceptance::factory()
->pending()
- ->create([
- 'alert_on_response_id' => $initiator->id,
- ]);
+ ->withAlertingTo($initiator)
+ ->create();
$this->acceptCheckout($checkoutAcceptance);
@@ -38,9 +37,8 @@ class CheckoutResponseEmailTest extends TestCase
$checkoutAcceptance = CheckoutAcceptance::factory()
->pending()
- ->create([
- 'alert_on_response_id' => $initiator->id,
- ]);
+ ->withAlertingTo($initiator)
+ ->create();
$this->declineCheckout($checkoutAcceptance);
@@ -53,9 +51,8 @@ class CheckoutResponseEmailTest extends TestCase
$checkoutAcceptance = CheckoutAcceptance::factory()
->pending()
- ->create([
- 'alert_on_response_id' => null,
- ]);
+ ->withoutAlerting()
+ ->create();
$this->acceptCheckout($checkoutAcceptance);
@@ -68,9 +65,8 @@ class CheckoutResponseEmailTest extends TestCase
$checkoutAcceptance = CheckoutAcceptance::factory()
->pending()
- ->create([
- 'alert_on_response_id' => null,
- ]);
+ ->withoutAlerting()
+ ->create();
$this->declineCheckout($checkoutAcceptance);