Skip to content

A free open source IT asset/license management system

FMCS: updated/added tests

snipe3dd5358e738d
diff --git a/tests/Feature/Accessories/Ui/CheckoutAccessoryTest.php b/tests/Feature/Accessories/Ui/CheckoutAccessoryTest.php
index 7c41d3aa49..132e57375a 100644
--- a/tests/Feature/Accessories/Ui/CheckoutAccessoryTest.php
+++ b/tests/Feature/Accessories/Ui/CheckoutAccessoryTest.php
@@ -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();
diff --git a/tests/Feature/Checkouts/Api/AssetCheckoutTest.php b/tests/Feature/Checkouts/Api/AssetCheckoutTest.php
index 6777e34e50..a5089a8cf1 100644
--- a/tests/Feature/Checkouts/Api/AssetCheckoutTest.php
+++ b/tests/Feature/Checkouts/Api/AssetCheckoutTest.php
@@ -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.