FMCS: updated/added tests

This commit is contained in:
snipe
2026-06-10 11:20:33 +01:00
parent 8cc4ad27c9
commit 3dd5358e73
2 changed files with 52 additions and 2 deletions
@@ -114,6 +114,56 @@ class CheckoutAccessoryTest extends TestCase
]);
}
public function test_checkout_to_null_company_user_blocked_in_strict_mode()
{
[$companyA] = Company::factory()->count(1)->create();
$accessory = Accessory::factory()->for($companyA)->create(['qty' => 5]);
$nullCompanyUser = User::factory()->create(['company_id' => null]);
$this->settings->enableMultipleFullCompanySupport();
$actor = User::factory()->superuser()->create();
$this->actingAs($actor)
->post(route('accessories.checkout.store', $accessory), [
'checkout_to_type' => 'user',
'assigned_user' => $nullCompanyUser->id,
'checkout_qty' => 1,
'redirect_option' => 'index',
])
->assertRedirect();
$this->assertDatabaseMissing('accessories_checkout', [
'accessory_id' => $accessory->id,
'assigned_to' => $nullCompanyUser->id,
]);
}
public function test_checkout_to_null_company_user_succeeds_in_floater_mode()
{
[$companyA] = Company::factory()->count(1)->create();
$accessory = Accessory::factory()->for($companyA)->create(['qty' => 5]);
$nullCompanyUser = User::factory()->create(['company_id' => null]);
$this->settings->enableFloaterMode();
$actor = User::factory()->superuser()->create();
$this->actingAs($actor)
->post(route('accessories.checkout.store', $accessory), [
'checkout_to_type' => 'user',
'assigned_user' => $nullCompanyUser->id,
'checkout_qty' => 1,
'redirect_option' => 'index',
])
->assertRedirect();
$this->assertDatabaseHas('accessories_checkout', [
'accessory_id' => $accessory->id,
'assigned_to' => $nullCompanyUser->id,
]);
}
public function test_checkout_to_location_does_not_throw_when_fmcs_enabled()
{
[$companyA] = Company::factory()->count(1)->create();
@@ -335,8 +335,8 @@ class AssetCheckoutTest extends TestCase
public function test_asset_can_be_checked_out_to_user_with_no_company_when_fmcs_enabled()
{
// Users with no company associations should not be blocked — they're unrestricted.
$this->settings->enableMultipleFullCompanySupport();
// In floater mode, users with no company associations can receive items from any company.
$this->settings->enableFloaterMode();
$company = Company::factory()->create();
// Actor is in the same company as the asset.