From 095a7d9b34c92b52aec1910365dbbaff1c19acd7 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 12 Feb 2024 12:54:48 -0800 Subject: [PATCH] Scaffold tests around accessory check in --- database/factories/AccessoryFactory.php | 13 +++++++ .../Feature/Checkins/AccessoryCheckinTest.php | 35 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/Feature/Checkins/AccessoryCheckinTest.php diff --git a/database/factories/AccessoryFactory.php b/database/factories/AccessoryFactory.php index 4066526770..acef32c2bd 100644 --- a/database/factories/AccessoryFactory.php +++ b/database/factories/AccessoryFactory.php @@ -8,6 +8,7 @@ use App\Models\Location; use App\Models\Manufacturer; use App\Models\Supplier; use App\Models\User; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\Factory; class AccessoryFactory extends Factory @@ -140,4 +141,16 @@ class AccessoryFactory extends Factory $accessory->category->update(['require_acceptance' => 1]); }); } + + public function checkedOut() + { + return $this->afterCreating(function (Accessory $accessory) { + $accessory->users()->attach($accessory->id, [ + 'accessory_id' => $accessory->id, + 'created_at' => Carbon::now(), + 'user_id' => 1, + 'assigned_to' => User::factory()->create()->id, + ]); + }); + } } diff --git a/tests/Feature/Checkins/AccessoryCheckinTest.php b/tests/Feature/Checkins/AccessoryCheckinTest.php new file mode 100644 index 0000000000..6d9d1ecf2e --- /dev/null +++ b/tests/Feature/Checkins/AccessoryCheckinTest.php @@ -0,0 +1,35 @@ +actingAs(User::factory()->create()) + ->post(route('accessories.checkin.store', Accessory::factory()->checkedOut()->create())) + ->assertForbidden(); + } + + public function testAccessoryCanBeCheckedIn() + { + $this->markTestIncomplete(); + } + + public function testEmailSentToUserIfSettingEnabled() + { + $this->markTestIncomplete(); + } + + public function testEmailNotSentToUserIfSettingDisabled() + { + $this->markTestIncomplete(); + } +}