diff --git a/tests/Feature/Api/Assets/AssetCheckinTest.php b/tests/Feature/Api/Assets/AssetCheckinTest.php index 85104052c1..77b64a3f8c 100644 --- a/tests/Feature/Api/Assets/AssetCheckinTest.php +++ b/tests/Feature/Api/Assets/AssetCheckinTest.php @@ -13,40 +13,34 @@ class AssetCheckinTest extends TestCase public function testCheckingInAssetRequiresCorrectPermission() { - $this->markTestIncomplete(); + $this->actingAsForApi(User::factory()->create()) + ->postJson(route('api.asset.checkin', Asset::factory()->assignedToUser()->create())) + ->assertForbidden(); } public function testCannotCheckInNonExistentAsset() { - $this->markTestIncomplete(); + $this->actingAsForApi(User::factory()->checkinAssets()->create()) + ->postJson(route('api.asset.checkin', ['id' => 'does-not-exist'])) + ->assertStatusMessageIs('error'); } public function testCannotCheckInAssetThatIsNotCheckedOut() { - $this->markTestIncomplete(); + $this->actingAsForApi(User::factory()->checkinAssets()->create()) + ->postJson(route('api.asset.checkin', Asset::factory()->create()->id)) + ->assertStatusMessageIs('error'); } - public function testAssetCheckedOutToAssetCanBeCheckedIn() - { - $this->markTestIncomplete(); - } - - public function testAssetCheckedOutToLocationCanBeCheckedIn() - { - $this->markTestIncomplete(); - } - - public function testAssetCheckedOutToUserCanBeCheckedIn() + public function testAssetCanBeCheckedIn() { $this->markTestIncomplete(); } public function testLastCheckInFieldIsSetOnCheckin() { - $admin = User::factory()->superuser()->create(); - $asset = Asset::factory()->create(['last_checkin' => null]); - - $asset->checkOut(User::factory()->create(), $admin, now()); + $admin = User::factory()->checkinAssets()->create(); + $asset = Asset::factory()->assignedToUser()->create(['last_checkin' => null]); $this->actingAsForApi($admin) ->postJson(route('api.asset.checkin', $asset)) diff --git a/tests/Feature/Checkins/AssetCheckinTest.php b/tests/Feature/Checkins/AssetCheckinTest.php index 433e824ddc..f951ede70a 100644 --- a/tests/Feature/Checkins/AssetCheckinTest.php +++ b/tests/Feature/Checkins/AssetCheckinTest.php @@ -116,13 +116,10 @@ class AssetCheckinTest extends TestCase public function testLastCheckInFieldIsSetOnCheckin() { - $admin = User::factory()->superuser()->create(); + $admin = User::factory()->checkinAssets()->create(); $asset = Asset::factory()->assignedToUser()->create(['last_checkin' => null]); - $this->actingAs($admin) - ->post(route('hardware.checkin.store', [ - 'assetId' => $asset->id, - ])); + $this->actingAs($admin)->post(route('hardware.checkin.store', ['assetId' => $asset->id])); $this->assertNotNull( $asset->refresh()->last_checkin,