Skip to content

A free open source IT asset/license management system

Cleanup

Marcus Mooredbc79655b007
diff --git a/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.php b/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.php
index 35345fac24..dbe79c5727 100644
--- a/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.php
+++ b/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.php
@@ -17,24 +17,24 @@ class EmailNotificationsUponCheckinTest extends TestCase
{
use InteractsWithSettings;
- public function testCheckInEmailSentToUserIfSettingEnabled()
+ protected function setUp(): void
{
+ parent::setUp();
+
Notification::fake();
+ }
+ public function testCheckInEmailSentToUserIfSettingEnabled()
+ {
$user = User::factory()->create();
$asset = Asset::factory()->assignedToUser($user)->create();
$asset->model->category->update(['checkin_email' => true]);
- event(new CheckoutableCheckedIn(
- $asset,
- $user,
- User::factory()->checkinAssets()->create(),
- ''
- ));
+ $this->fireCheckInEvent($asset, $user);
Notification::assertSentTo(
- [$user],
+ $user,
function (CheckinAssetNotification $notification, $channels) {
return in_array('mail', $channels);
},
@@ -43,25 +43,28 @@ class EmailNotificationsUponCheckinTest extends TestCase
public function testCheckInEmailNotSentToUserIfSettingDisabled()
{
- Notification::fake();
-
$user = User::factory()->create();
$asset = Asset::factory()->assignedToUser($user)->create();
$asset->model->category->update(['checkin_email' => false]);
- event(new CheckoutableCheckedIn(
- $asset,
- $user,
- User::factory()->checkinAssets()->create(),
- ''
- ));
+ $this->fireCheckInEvent($asset, $user);
Notification::assertNotSentTo(
- [$user],
+ $user,
function (CheckinAssetNotification $notification, $channels) {
return in_array('mail', $channels);
}
);
}
+
+ private function fireCheckInEvent($asset, $user): void
+ {
+ event(new CheckoutableCheckedIn(
+ $asset,
+ $user,
+ User::factory()->checkinAssets()->create(),
+ ''
+ ));
+ }
}