Fixed test for RMB

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2025-02-22 18:08:25 +00:00
parent a0a0727b5c
commit 1b9d046f5f

View file

@ -18,16 +18,14 @@ class AssetCheckinTest extends TestCase
public function testCheckingInAssetRequiresCorrectPermission()
{
$this->actingAs(User::factory()->create())
->post(route('hardware.checkin.store', [
'assetId' => Asset::factory()->assignedToUser()->create()->id,
]))
->post(route('hardware.checkin.store', [Asset::factory()->assignedToUser()->create()]))
->assertForbidden();
}
public function testCannotCheckInAssetThatIsNotCheckedOut()
{
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route('hardware.checkin.store', ['assetId' => Asset::factory()->create()->id]))
->post(route('hardware.checkin.store', [Asset::factory()->create()]))
->assertStatus(302)
->assertSessionHas('error')
->assertRedirect(route('hardware.index'));
@ -36,7 +34,7 @@ class AssetCheckinTest extends TestCase
public function testCannotStoreAssetCheckinThatIsNotCheckedOut()
{
$this->actingAs(User::factory()->checkinAssets()->create())
->get(route('hardware.checkin.store', ['assetId' => Asset::factory()->create()->id]))
->get(route('hardware.checkin.store', [Asset::factory()->create()]))
->assertStatus(302)
->assertSessionHas('error')
->assertRedirect(route('hardware.index'));
@ -68,7 +66,7 @@ class AssetCheckinTest extends TestCase
$this->actingAs(User::factory()->checkinAssets()->create())
->post(
route('hardware.checkin.store', ['assetId' => $asset->id]),
route('hardware.checkin.store', [$asset]),
[
'name' => 'Changed Name',
'status_id' => $status->id,
@ -101,7 +99,7 @@ class AssetCheckinTest extends TestCase
]);
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
->post(route('hardware.checkin.store', [$asset]));
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
}
@ -112,7 +110,7 @@ class AssetCheckinTest extends TestCase
$asset = Asset::factory()->assignedToUser()->create();
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route('hardware.checkin.store', ['assetId' => $asset->id]), [
->post(route('hardware.checkin.store', [$asset]), [
'location_id' => $location->id,
'update_default_location' => 0
]);
@ -128,7 +126,7 @@ class AssetCheckinTest extends TestCase
$this->assertNotNull($asset->licenseseats->first()->assigned_to);
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
->post(route('hardware.checkin.store', [$asset]));
$this->assertNull($asset->refresh()->licenseseats->first()->assigned_to);
}
@ -141,7 +139,7 @@ class AssetCheckinTest extends TestCase
]);
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
->post(route('hardware.checkin.store', [$asset]));
$this->assertNull($asset->refresh()->rtd_location_id);
$this->assertEquals($asset->location_id, $asset->rtd_location_id);
@ -154,7 +152,7 @@ class AssetCheckinTest extends TestCase
$acceptance = CheckoutAcceptance::factory()->for($asset, 'checkoutable')->pending()->create();
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
->post(route('hardware.checkin.store', [$asset]));
$this->assertFalse($acceptance->exists(), 'Acceptance was not deleted');
}
@ -165,8 +163,7 @@ class AssetCheckinTest extends TestCase
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route(
'hardware.checkin.store',
['assetId' => Asset::factory()->assignedToUser()->create()->id]
'hardware.checkin.store', [Asset::factory()->assignedToUser()->create()]
), [
'checkin_at' => '2023-01-02',
'note' => 'hello'
@ -185,10 +182,10 @@ class AssetCheckinTest extends TestCase
$asset->forceSave();
$this->actingAs(User::factory()->admin()->create())
->get(route('hardware.checkin.create', ['assetId' => $asset->id]))
->get(route('hardware.checkin.create', [$asset]))
->assertStatus(302)
->assertSessionHas('error')
->assertRedirect(route('hardware.show', $asset->id));
->assertRedirect(route('hardware.show', $asset));
}
public function testAssetCheckinPagePostIsRedirectedIfModelIsInvalid()
@ -198,7 +195,7 @@ class AssetCheckinTest extends TestCase
$asset->forceSave();
$this->actingAs(User::factory()->admin()->create())
->post(route('hardware.checkin.store', ['assetId' => $asset->id]))
->post(route('hardware.checkin.store', $asset))
->assertStatus(302)
->assertSessionHas('error')
->assertRedirect(route('hardware.show', $asset));