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()
{
$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))

View file

@ -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,