Add failing test

This commit is contained in:
Marcus Moore
2025-09-18 17:14:33 -07:00
parent 41da31c379
commit 5c08f3a27e

View File

@@ -89,4 +89,32 @@ class BulkAssetCheckoutTest extends TestCase
$this->fail('Asset checkout email was sent when the entire checkout failed.');
}
}
public function test_prevents_checkouts_checked_out_items()
{
$asset = Asset::factory()->create();
$checkedOutAsset = Asset::factory()->assignedToUser()->create();
$existingUserId = $checkedOutAsset->assigned_to;
$target = User::factory()->create();
$response = $this->actingAs(User::factory()->superuser()->create())
->post(route('hardware.bulkcheckout.store'), [
'selected_assets' => [
$asset->id,
$checkedOutAsset->id,
],
'checkout_to_type' => 'user',
'assigned_user' => $target->id,
]);
$this->assertEquals(
$existingUserId,
$checkedOutAsset->fresh()->assigned_to,
'Asset was checked out when it should have been prevented.'
);
// ensure redirected back
$response->assertRedirectToRoute('hardware.bulkcheckout.show');
}
}