Skip to content

A free open source IT asset/license management system

Readability

Marcus Mooredad650b80486
diff --git a/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php b/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php
index cfd7513c6b..e2b6016535 100644
--- a/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php
+++ b/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php
@@ -231,40 +231,30 @@ class BulkCheckoutEmailTest extends TestCase
private function sendRequest()
{
- $this->actingAs($this->admin)
- ->followingRedirects()
- ->post(route('hardware.bulkcheckout.store'), array_merge([
- 'selected_assets' => $this->assets->pluck('id')->toArray(),
- 'checkout_at' => now()->subWeek()->format('Y-m-d'),
- 'expected_checkin' => now()->addWeek()->format('Y-m-d'),
- 'note' => null,
- ], $this->getAssignedArray()))
- ->assertOk();
- }
-
- private function getAssignedArray(): array
- {
- if ($this->target instanceof User) {
- return [
+ $assigned = match (get_class($this->target)) {
+ User::class => [
'checkout_to_type' => 'user',
'assigned_user' => $this->target->id,
- ];
- }
-
- if ($this->target instanceof Location) {
- return [
+ ],
+ Location::class => [
'checkout_to_type' => 'location',
'assigned_location' => $this->target->id,
- ];
- }
-
- if ($this->target instanceof Asset) {
- return [
+ ],
+ Asset::class => [
'checkout_to_type' => 'asset',
'assigned_asset' => $this->target->id,
- ];
- }
+ ],
+ default => [],
+ };
- throw new RuntimeException('invalid target type');
+ $this->actingAs($this->admin)
+ ->followingRedirects()
+ ->post(route('hardware.bulkcheckout.store'), [
+ 'selected_assets' => $this->assets->pluck('id')->toArray(),
+ 'checkout_at' => now()->subWeek()->format('Y-m-d'),
+ 'expected_checkin' => now()->addWeek()->format('Y-m-d'),
+ 'note' => null,
+ ] + $assigned)
+ ->assertOk();
}
}