diff --git a/tests/Feature/Checkins/Ui/AccessoryCheckinTest.php b/tests/Feature/Checkins/Ui/AccessoryCheckinTest.php index 7a99b2ab56..56d429ac56 100644 --- a/tests/Feature/Checkins/Ui/AccessoryCheckinTest.php +++ b/tests/Feature/Checkins/Ui/AccessoryCheckinTest.php @@ -3,10 +3,12 @@ namespace Tests\Feature\Checkins\Ui; use App\Events\CheckoutableCheckedIn; +use App\Mail\CheckoutAccessoryMail; use App\Models\Accessory; use App\Models\User; use App\Notifications\CheckinAccessoryNotification; use Illuminate\Support\Facades\Event; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Notification; use Tests\TestCase; @@ -40,7 +42,7 @@ class AccessoryCheckinTest extends TestCase public function testEmailSentToUserIfSettingEnabled() { - Notification::fake(); + Mail::fake(); $user = User::factory()->create(); $accessory = Accessory::factory()->checkedOutToUser($user)->create(); @@ -54,17 +56,14 @@ class AccessoryCheckinTest extends TestCase '', )); - Notification::assertSentTo( - [$user], - function (CheckinAccessoryNotification $notification, $channels) { - return in_array('mail', $channels); - }, - ); + Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) { + return $mail->hasTo($user) && $mail->contains($accessory); + }); } public function testEmailNotSentToUserIfSettingDisabled() { - Notification::fake(); + Mail::fake(); $user = User::factory()->create(); $accessory = Accessory::factory()->checkedOutToUser($user)->create(); @@ -78,11 +77,8 @@ class AccessoryCheckinTest extends TestCase '', )); - Notification::assertNotSentTo( - [$user], - function (CheckinAccessoryNotification $notification, $channels) { - return in_array('mail', $channels); - }, - ); + Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) { + return $mail->hasTo($user) && $mail->contains($accessory); + }); } } diff --git a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php index f63a8471f2..fedc1a2584 100644 --- a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php @@ -2,12 +2,14 @@ namespace Tests\Feature\Checkouts\Ui; +use App\Mail\CheckoutAccessoryMail; use App\Models\Accessory; use App\Models\Actionlog; use App\Models\Asset; use App\Models\Location; use App\Models\User; use App\Notifications\CheckoutAccessoryNotification; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Notification; use Tests\TestCase; @@ -156,7 +158,7 @@ class AccessoryCheckoutTest extends TestCase public function testUserSentNotificationUponCheckout() { - Notification::fake(); + Mail::fake(); $accessory = Accessory::factory()->requiringAcceptance()->create(); $user = User::factory()->create(); @@ -168,7 +170,9 @@ class AccessoryCheckoutTest extends TestCase 'checkout_to_type' => 'user', ]); - Notification::assertSentTo($user, CheckoutAccessoryNotification::class); + Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) { + return $mail->hasTo($user) && $mail->contains($accessory); + }); } public function testActionLogCreatedUponCheckout() diff --git a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php index 46c34aedd7..2ce4a04533 100644 --- a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature\Checkouts\Ui; +use App\Mail\CheckoutConsumableMail; use App\Models\Actionlog; use App\Models\Asset; use App\Models\Component; @@ -64,7 +65,7 @@ class ConsumableCheckoutTest extends TestCase 'assigned_to' => $user->id, ]); - Mail::assertSent(CheckoutConsumableNotification::class, function ($mail) use ($consumable, $user) { + Mail::assertSent(CheckoutConsumableMail::class, function ($mail) use ($consumable, $user) { return $mail->hasTo($user) && $mail->consumables->contains($consumable); }); } diff --git a/tests/Feature/Importing/Api/ImportAssetsTest.php b/tests/Feature/Importing/Api/ImportAssetsTest.php index e001add381..66cc5174c4 100644 --- a/tests/Feature/Importing/Api/ImportAssetsTest.php +++ b/tests/Feature/Importing/Api/ImportAssetsTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature\Importing\Api; +use App\Mail\CheckoutAssetMail; use App\Models\Actionlog as ActionLog; use App\Models\Asset; use App\Models\CustomField; @@ -11,6 +12,7 @@ use App\Notifications\CheckoutAssetNotification; use Carbon\Carbon; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Notification; use Illuminate\Support\Str; use Illuminate\Testing\TestResponse; @@ -54,7 +56,7 @@ class ImportAssetsTest extends ImportDataTestCase implements TestsPermissionsReq #[Test] public function importAsset(): void { - Notification::fake(); + Mail::fake(); $importFileBuilder = ImportFileBuilder::new(); $row = $importFileBuilder->firstRow(); @@ -138,7 +140,7 @@ class ImportAssetsTest extends ImportDataTestCase implements TestsPermissionsReq //Notes is never read. // $this->assertEquals($row['notes'], $newAsset->notes); - Notification::assertSentTo($assignee, CheckoutAssetNotification::class); + Mail::assertSent($assignee, CheckoutAssetMail::class); } #[Test]