From 6fc06f2ee1710ef30d3e59c10167addc6dc1f8d0 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 21 Aug 2023 12:31:51 -0700 Subject: [PATCH] Add simple tests around asset check in --- tests/Feature/Api/Assets/AssetCheckinTest.php | 30 +++++++++++++++++ tests/Feature/Assets/AssetCheckinTest.php | 32 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/Feature/Api/Assets/AssetCheckinTest.php create mode 100644 tests/Feature/Assets/AssetCheckinTest.php diff --git a/tests/Feature/Api/Assets/AssetCheckinTest.php b/tests/Feature/Api/Assets/AssetCheckinTest.php new file mode 100644 index 0000000000..f71191d80c --- /dev/null +++ b/tests/Feature/Api/Assets/AssetCheckinTest.php @@ -0,0 +1,30 @@ +superuser()->create(); + $asset = Asset::factory()->create(['last_checkin' => null]); + + $asset->checkOut(User::factory()->create(), $admin, now()); + + $this->actingAsForApi($admin) + ->postJson(route('api.asset.checkin', $asset)) + ->assertOk(); + + $this->assertNotNull( + $asset->fresh()->last_checkin, + 'last_checkin field should be set on checkin' + ); + } +} diff --git a/tests/Feature/Assets/AssetCheckinTest.php b/tests/Feature/Assets/AssetCheckinTest.php new file mode 100644 index 0000000000..059fb1294f --- /dev/null +++ b/tests/Feature/Assets/AssetCheckinTest.php @@ -0,0 +1,32 @@ +superuser()->create(); + $asset = Asset::factory()->create(['last_checkin' => null]); + + $asset->checkOut(User::factory()->create(), $admin, now()); + + $this->actingAs($admin) + ->post(route('hardware.checkin.store', [ + 'assetId' => $asset->id, + ])) + ->assertRedirect(); + + $this->assertNotNull( + $asset->fresh()->last_checkin, + 'last_checkin field should be set on checkin' + ); + } +}