Implement tests

This commit is contained in:
Marcus Moore 2024-02-13 17:50:26 -08:00
parent 9ab56fe9ca
commit ad1846fed6
No known key found for this signature in database
2 changed files with 14 additions and 23 deletions

View file

@ -13,40 +13,34 @@ class AssetCheckinTest extends TestCase
public function testCheckingInAssetRequiresCorrectPermission() public function testCheckingInAssetRequiresCorrectPermission()
{ {
$this->markTestIncomplete(); $this->actingAsForApi(User::factory()->create())
->postJson(route('api.asset.checkin', Asset::factory()->assignedToUser()->create()))
->assertForbidden();
} }
public function testCannotCheckInNonExistentAsset() 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() 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() public function testAssetCanBeCheckedIn()
{
$this->markTestIncomplete();
}
public function testAssetCheckedOutToLocationCanBeCheckedIn()
{
$this->markTestIncomplete();
}
public function testAssetCheckedOutToUserCanBeCheckedIn()
{ {
$this->markTestIncomplete(); $this->markTestIncomplete();
} }
public function testLastCheckInFieldIsSetOnCheckin() public function testLastCheckInFieldIsSetOnCheckin()
{ {
$admin = User::factory()->superuser()->create(); $admin = User::factory()->checkinAssets()->create();
$asset = Asset::factory()->create(['last_checkin' => null]); $asset = Asset::factory()->assignedToUser()->create(['last_checkin' => null]);
$asset->checkOut(User::factory()->create(), $admin, now());
$this->actingAsForApi($admin) $this->actingAsForApi($admin)
->postJson(route('api.asset.checkin', $asset)) ->postJson(route('api.asset.checkin', $asset))

View file

@ -116,13 +116,10 @@ class AssetCheckinTest extends TestCase
public function testLastCheckInFieldIsSetOnCheckin() public function testLastCheckInFieldIsSetOnCheckin()
{ {
$admin = User::factory()->superuser()->create(); $admin = User::factory()->checkinAssets()->create();
$asset = Asset::factory()->assignedToUser()->create(['last_checkin' => null]); $asset = Asset::factory()->assignedToUser()->create(['last_checkin' => null]);
$this->actingAs($admin) $this->actingAs($admin)->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
->post(route('hardware.checkin.store', [
'assetId' => $asset->id,
]));
$this->assertNotNull( $this->assertNotNull(
$asset->refresh()->last_checkin, $asset->refresh()->last_checkin,