diff --git a/tests/Feature/Api/Assets/AssetCheckinTest.php b/tests/Feature/Api/Assets/AssetCheckinTest.php index 8f806ada93..32aed3616e 100644 --- a/tests/Feature/Api/Assets/AssetCheckinTest.php +++ b/tests/Feature/Api/Assets/AssetCheckinTest.php @@ -120,14 +120,4 @@ class AssetCheckinTest extends TestCase { $this->markTestIncomplete(); } - - public function testCheckInEmailSentToUserIfSettingEnabled() - { - $this->markTestIncomplete(); - } - - public function testCheckInEmailNotSentToUserIfSettingDisabled() - { - $this->markTestIncomplete(); - } } diff --git a/tests/Feature/Checkins/AssetCheckinTest.php b/tests/Feature/Checkins/AssetCheckinTest.php index 7a4074370c..5bd19175bf 100644 --- a/tests/Feature/Checkins/AssetCheckinTest.php +++ b/tests/Feature/Checkins/AssetCheckinTest.php @@ -9,9 +9,7 @@ use App\Models\LicenseSeat; use App\Models\Location; use App\Models\Statuslabel; use App\Models\User; -use App\Notifications\CheckinAssetNotification; use Illuminate\Support\Facades\Event; -use Illuminate\Support\Facades\Notification; use Tests\Support\InteractsWithSettings; use Tests\TestCase; @@ -169,52 +167,4 @@ class AssetCheckinTest extends TestCase return $event->action_date === '2023-01-02 12:45:56' && $event->note === 'hello'; }, 1); } - - public function testCheckInEmailSentToUserIfSettingEnabled() - { - Notification::fake(); - - $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(), - '' - )); - - Notification::assertSentTo( - [$user], - function (CheckinAssetNotification $notification, $channels) { - return in_array('mail', $channels); - }, - ); - } - - 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(), - '' - )); - - Notification::assertNotSentTo( - [$user], - function (CheckinAssetNotification $notification, $channels) { - return in_array('mail', $channels); - } - ); - } } diff --git a/tests/Feature/Notifications/AssetWebhookTest.php b/tests/Feature/Notifications/AssetWebhookTest.php index ae45a4caa4..f7df7bf356 100644 --- a/tests/Feature/Notifications/AssetWebhookTest.php +++ b/tests/Feature/Notifications/AssetWebhookTest.php @@ -108,6 +108,54 @@ class AssetWebhookTest extends TestCase Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAssetNotification::class); } + public function testCheckInEmailSentToUserIfSettingEnabled() + { + Notification::fake(); + + $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(), + '' + )); + + Notification::assertSentTo( + [$user], + function (CheckinAssetNotification $notification, $channels) { + return in_array('mail', $channels); + }, + ); + } + + 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(), + '' + )); + + Notification::assertNotSentTo( + [$user], + function (CheckinAssetNotification $notification, $channels) { + return in_array('mail', $channels); + } + ); + } + private function createAsset() { return Asset::factory()->laptopMbp()->create();