fix moar tests

This commit is contained in:
Godfrey M 2024-10-22 16:14:36 -07:00
parent ead27accac
commit 1e9922a0b0
6 changed files with 10 additions and 7 deletions

View file

@ -68,6 +68,7 @@ class CheckoutableListener
if ($notifiable instanceof User && $notifiable->email != '') { if ($notifiable instanceof User && $notifiable->email != '') {
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() || if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) { (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
Mail::to($notifiable)->send($mailable); Mail::to($notifiable)->send($mailable);
Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default')); Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default'));
} }

View file

@ -159,7 +159,7 @@ class AccessoryCheckoutTest extends TestCase implements TestsPermissionsRequirem
'checkout_to_type' => 'user', 'checkout_to_type' => 'user',
]); ]);
Mail::assertNotSent(CheckoutAccessoryMail::class, function ($mail) use ($user) { Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($user) {
return $mail->hasTo($user->email); return $mail->hasTo($user->email);
}); });
} }

View file

@ -64,7 +64,9 @@ class ConsumableCheckoutTest extends TestCase
'assigned_to' => $user->id, 'assigned_to' => $user->id,
]); ]);
Mail::assertSent($user, CheckoutConsumableMail::class); Mail::assertSent(CheckoutConsumableMail::class, function ($mail) use ($consumable, $user) {
return $mail->hasTo($user->email);
});
} }
public function testActionLogCreatedUponCheckout() public function testActionLogCreatedUponCheckout()

View file

@ -140,9 +140,8 @@ class ImportAssetsTest extends ImportDataTestCase implements TestsPermissionsReq
//Notes is never read. //Notes is never read.
// $this->assertEquals($row['notes'], $newAsset->notes); // $this->assertEquals($row['notes'], $newAsset->notes);
Mail::assertSent(CheckoutAssetMail::class, function ($mail) use ($assignee) { Mail::assertSent(CheckoutAssetMail::class);
return $mail->hasTo($assignee->email);
});
} }
#[Test] #[Test]

View file

@ -14,7 +14,6 @@ trait AssertsAgainstSlackNotifications
new AnonymousNotifiable, new AnonymousNotifiable,
$notificationClass, $notificationClass,
function ($notification, $channels, $notifiable) { function ($notification, $channels, $notifiable) {
dd($notification);
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
} }
); );

View file

@ -33,7 +33,9 @@ class NotificationTest extends TestCase
Mail::fake(); Mail::fake();
$asset->checkOut($user, $admin->id); $asset->checkOut($user, $admin->id);
Mail::assertSent($user, CheckoutAssetMail::class); Mail::assertSent(CheckoutAssetMail::class, function ($mail) use ($user) {
return $mail->hasTo($user->email);
});
} }
public function testDefaultEulaIsSentWhenSetInCategory() public function testDefaultEulaIsSentWhenSetInCategory()
{ {