From 89cfafd933ec24917fbab85559ea237b824a9d6e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Sep 2025 13:40:34 -0700 Subject: [PATCH 01/13] Scaffold test --- .../Checkouts/Ui/BulkAssetCheckoutTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index f05c4389e6..433f89d040 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -89,4 +89,21 @@ class BulkAssetCheckoutTest extends TestCase $this->fail('Asset checkout email was sent when the entire checkout failed.'); } } + + public function test_adheres_to_full_multiple_company_support() + { + $this->markTestIncomplete(); + + // create two companies + + // create an asset for each company + + // create a user for one company + + // create a super admin and act as them + + // attempt to bulk checkout both items to the user in the company + + // ensure bulk checkout is blocked + } } From d2157868f2b4fa2ac91b180108add764223840a1 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Sep 2025 13:49:32 -0700 Subject: [PATCH 02/13] Populate failing test --- .../Checkouts/Ui/BulkAssetCheckoutTest.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index 433f89d040..e7089bd188 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature\Checkouts\Ui; use App\Mail\CheckoutAssetMail; use App\Models\Asset; +use App\Models\Company; use App\Models\User; use Illuminate\Support\Facades\Mail; use PHPUnit\Framework\ExpectationFailedException; @@ -92,18 +93,39 @@ class BulkAssetCheckoutTest extends TestCase public function test_adheres_to_full_multiple_company_support() { - $this->markTestIncomplete(); + // $this->markTestIncomplete(); + $this->settings->enableMultipleFullCompanySupport(); // create two companies + [$companyA, $companyB] = Company::factory()->count(2)->create(); // create an asset for each company + $assetForCompanyA = Asset::factory()->for($companyA)->create(); + $assetForCompanyB = Asset::factory()->for($companyB)->create(); + + $this->assertNull($assetForCompanyA->assigned_to, 'Asset should not be assigned before attempting this test case.'); + $this->assertNull($assetForCompanyB->assigned_to, 'Asset should not be assigned before attempting this test case.'); // create a user for one company + $userInCompanyA = User::factory()->for($companyA)->create(); // create a super admin and act as them + $admin = User::factory()->superuser()->create(); // attempt to bulk checkout both items to the user in the company + $this->actingAs($admin) + ->post(route('hardware.bulkcheckout.store'), [ + 'selected_assets' => [ + $assetForCompanyA->id, + $assetForCompanyB->id, + ], + 'checkout_to_type' => 'user', + 'assigned_user' => $userInCompanyA->id, + ]); + // @todo: assert session has error message and redirect back // ensure bulk checkout is blocked + $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); + $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); } } From e29b0aa6a4bbb3a05b4b8b5f398b1ea8621cc4e1 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Sep 2025 13:55:54 -0700 Subject: [PATCH 03/13] Add todo --- tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index e7089bd188..8d90e15b5a 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -128,4 +128,6 @@ class BulkAssetCheckoutTest extends TestCase $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); } + + // @todo: another test for asset to asset and asset to location ❓ } From e639d7726b0669e22503e302084dfb345e84572b Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Sep 2025 14:32:27 -0700 Subject: [PATCH 04/13] Disallow bulk checkout across companies --- .../Controllers/Assets/BulkAssetsController.php | 15 +++++++++++++++ .../Checkouts/Ui/BulkAssetCheckoutTest.php | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 6c75ae06db..90e306d8c3 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -647,6 +647,21 @@ class BulkAssetsController extends Controller $assets = Asset::findOrFail($asset_ids); + if (Setting::getSettings()->full_multiple_companies_support && $target->company_id) { + $company_ids = $assets->pluck('company_id')->unique(); + + // if there is more than one unique company id or the singular company id does not match + // then the checkout is invalid + if ($company_ids->count() > 1 || $company_ids->first() != $target->company_id) { + // keep the session data around for the redirect so the assets select is re-populated + session()->reflash(); + + return redirect(route('hardware.bulkcheckout.show')) + // @todo: improve message and translate + ->with('error', 'One or more of the assets has a company mismatch.'); + } + } + if (request('checkout_to_type') == 'asset') { foreach ($asset_ids as $asset_id) { if ($target->id == $asset_id) { diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index 8d90e15b5a..b28e38f018 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -121,8 +121,8 @@ class BulkAssetCheckoutTest extends TestCase ], 'checkout_to_type' => 'user', 'assigned_user' => $userInCompanyA->id, - ]); - // @todo: assert session has error message and redirect back + ]) + ->assertRedirectToRoute('hardware.bulkcheckout.show'); // ensure bulk checkout is blocked $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); From b2ad9d404ed9b59aa4313b0617db3d2f4a6cc507 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 12:38:11 -0700 Subject: [PATCH 05/13] Fix re-population of assets --- app/Http/Controllers/Assets/BulkAssetsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 90e306d8c3..74b342c2f3 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -653,8 +653,8 @@ class BulkAssetsController extends Controller // if there is more than one unique company id or the singular company id does not match // then the checkout is invalid if ($company_ids->count() > 1 || $company_ids->first() != $target->company_id) { - // keep the session data around for the redirect so the assets select is re-populated - session()->reflash(); + // re-add the asset ids so the assets select is re-populated + $request->session()->flashInput(['selected_assets' => $asset_ids]); return redirect(route('hardware.bulkcheckout.show')) // @todo: improve message and translate From 47e9e4704dca657bfb7e702c691534da036d6b28 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 12:56:36 -0700 Subject: [PATCH 06/13] Improve error message --- app/Http/Controllers/Assets/BulkAssetsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 74b342c2f3..db0190e626 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -658,7 +658,7 @@ class BulkAssetsController extends Controller return redirect(route('hardware.bulkcheckout.show')) // @todo: improve message and translate - ->with('error', 'One or more of the assets has a company mismatch.'); + ->with('error', 'One or more of the checkout target company and asset company do not match'); } } From a02a96d5c41babaca467387bea6a220017481001 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 12:57:56 -0700 Subject: [PATCH 07/13] Extract translation string --- app/Http/Controllers/Assets/BulkAssetsController.php | 3 +-- resources/lang/en-US/general.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index db0190e626..463c7d2dbd 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -657,8 +657,7 @@ class BulkAssetsController extends Controller $request->session()->flashInput(['selected_assets' => $asset_ids]); return redirect(route('hardware.bulkcheckout.show')) - // @todo: improve message and translate - ->with('error', 'One or more of the checkout target company and asset company do not match'); + ->with('error', trans('general.error_user_company_multiple')); } } diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 61b7c9f809..5941682bfc 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -519,6 +519,7 @@ return [ 'item_notes' => ':item Notes', 'item_name_var' => ':item Name', 'error_user_company' => 'Checkout target company and asset company do not match', + 'error_user_company_multiple' => 'One or more of the checkout target company and asset company do not match', 'error_user_company_accept_view' => 'An Asset assigned to you belongs to a different company so you can\'t accept nor deny it, please check with your manager', 'importer' => [ 'checked_out_to_fullname' => 'Checked Out to: Full Name', From c58e999fbb251bf6dce5d15a027fb535bf30a3a7 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 13:11:06 -0700 Subject: [PATCH 08/13] Scaffold tests --- .../Feature/Checkouts/Ui/BulkAssetCheckoutTest.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index b28e38f018..2303bb9ef8 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -91,9 +91,8 @@ class BulkAssetCheckoutTest extends TestCase } } - public function test_adheres_to_full_multiple_company_support() + public function test_adheres_to_full_multiple_company_support_when_checking_out_to_user() { - // $this->markTestIncomplete(); $this->settings->enableMultipleFullCompanySupport(); // create two companies @@ -129,5 +128,14 @@ class BulkAssetCheckoutTest extends TestCase $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); } - // @todo: another test for asset to asset and asset to location ❓ + public function test_adheres_to_full_multiple_company_support_when_checking_out_to_asset() + { + $this->markTestIncomplete(); + } + + public function test_adheres_to_full_multiple_company_support_when_checking_out_to_location() + { + $this->markTestIncomplete(); + + } } From 27d13a113aa9171ad1f225f1be2e2bdacac4bd7c Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 14:01:44 -0700 Subject: [PATCH 09/13] Implement test --- .../Checkouts/Ui/BulkAssetCheckoutTest.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index 2303bb9ef8..2c95db26c5 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -130,7 +130,41 @@ class BulkAssetCheckoutTest extends TestCase public function test_adheres_to_full_multiple_company_support_when_checking_out_to_asset() { - $this->markTestIncomplete(); + $this->settings->enableMultipleFullCompanySupport(); + + // create two companies + [$companyA, $companyB] = Company::factory()->count(2)->create(); + + // create an asset for each company + $assetForCompanyA = Asset::factory()->for($companyA)->create(); + $assetForCompanyB = Asset::factory()->for($companyB)->create(); + + $this->assertNull($assetForCompanyA->assigned_to, 'Asset should not be assigned before attempting this test case.'); + $this->assertNull($assetForCompanyB->assigned_to, 'Asset should not be assigned before attempting this test case.'); + + // create an asset for one company + $targetAssetForCompanyA = Asset::factory()->for($companyA)->create(); + + // create a super admin and act as them + $admin = User::factory()->superuser()->create(); + + // attempt to bulk checkout both items to the user in the company + $response = $this->actingAs($admin) + ->post(route('hardware.bulkcheckout.store'), [ + 'selected_assets' => [ + $assetForCompanyA->id, + $assetForCompanyB->id, + ], + 'checkout_to_type' => 'asset', + 'assigned_asset' => $targetAssetForCompanyA->id, + ]); + + // ensure bulk checkout is blocked + $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); + $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); + + // ensure redirected back + $response->assertRedirectToRoute('hardware.bulkcheckout.show'); } public function test_adheres_to_full_multiple_company_support_when_checking_out_to_location() From 59d0f0d292e8192534fa1a24fdaef5a1654fa8cc Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 14:05:13 -0700 Subject: [PATCH 10/13] Re-order assertions --- tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index 2c95db26c5..397215f2f3 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -112,7 +112,7 @@ class BulkAssetCheckoutTest extends TestCase $admin = User::factory()->superuser()->create(); // attempt to bulk checkout both items to the user in the company - $this->actingAs($admin) + $response = $this->actingAs($admin) ->post(route('hardware.bulkcheckout.store'), [ 'selected_assets' => [ $assetForCompanyA->id, @@ -120,12 +120,14 @@ class BulkAssetCheckoutTest extends TestCase ], 'checkout_to_type' => 'user', 'assigned_user' => $userInCompanyA->id, - ]) - ->assertRedirectToRoute('hardware.bulkcheckout.show'); + ]); // ensure bulk checkout is blocked $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); + + // ensure redirected back + $response->assertRedirectToRoute('hardware.bulkcheckout.show'); } public function test_adheres_to_full_multiple_company_support_when_checking_out_to_asset() From 17aab4c4906b339407e9f33402795832bd5e23ff Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 14:20:05 -0700 Subject: [PATCH 11/13] Implement test --- .../Checkouts/Ui/BulkAssetCheckoutTest.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index 397215f2f3..56866d201c 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature\Checkouts\Ui; use App\Mail\CheckoutAssetMail; use App\Models\Asset; use App\Models\Company; +use App\Models\Location; use App\Models\User; use Illuminate\Support\Facades\Mail; use PHPUnit\Framework\ExpectationFailedException; @@ -171,7 +172,40 @@ class BulkAssetCheckoutTest extends TestCase public function test_adheres_to_full_multiple_company_support_when_checking_out_to_location() { - $this->markTestIncomplete(); + $this->settings->enableMultipleFullCompanySupport(); + // create two companies + [$companyA, $companyB] = Company::factory()->count(2)->create(); + + // create an asset for each company + $assetForCompanyA = Asset::factory()->for($companyA)->create(); + $assetForCompanyB = Asset::factory()->for($companyB)->create(); + + $this->assertNull($assetForCompanyA->assigned_to, 'Asset should not be assigned before attempting this test case.'); + $this->assertNull($assetForCompanyB->assigned_to, 'Asset should not be assigned before attempting this test case.'); + + // create a location for one company + $locationForCompanyA = Location::factory()->for($companyA)->create(); + + // create a super admin and act as them + $admin = User::factory()->superuser()->create(); + + // attempt to bulk checkout both items to the user in the company + $response = $this->actingAs($admin) + ->post(route('hardware.bulkcheckout.store'), [ + 'selected_assets' => [ + $assetForCompanyA->id, + $assetForCompanyB->id, + ], + 'checkout_to_type' => 'location', + 'assigned_location' => $locationForCompanyA->id, + ]); + + // ensure bulk checkout is blocked + $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); + $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); + + // ensure redirected back + $response->assertRedirectToRoute('hardware.bulkcheckout.show'); } } From 2960ea15f5c61f74de7ca77d9ca5776bb745930e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 14:29:12 -0700 Subject: [PATCH 12/13] Consolidate to data provider --- .../Checkouts/Ui/BulkAssetCheckoutTest.php | 118 +++++------------- 1 file changed, 34 insertions(+), 84 deletions(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index 56866d201c..f9b9398bd2 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -8,6 +8,7 @@ use App\Models\Company; use App\Models\Location; use App\Models\User; use Illuminate\Support\Facades\Mail; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\ExpectationFailedException; use Tests\TestCase; @@ -92,47 +93,41 @@ class BulkAssetCheckoutTest extends TestCase } } - public function test_adheres_to_full_multiple_company_support_when_checking_out_to_user() + public static function checkoutTargets() { - $this->settings->enableMultipleFullCompanySupport(); + yield 'Checkout to user' => [ + function () { + return [ + 'type' => 'user', + 'target' => User::factory()->forCompany()->create(), + ]; + } + ]; - // create two companies - [$companyA, $companyB] = Company::factory()->count(2)->create(); + yield 'Checkout to asset' => [ + function () { + return [ + 'type' => 'asset', + 'target' => Asset::factory()->forCompany()->create(), + ]; + } + ]; - // create an asset for each company - $assetForCompanyA = Asset::factory()->for($companyA)->create(); - $assetForCompanyB = Asset::factory()->for($companyB)->create(); - - $this->assertNull($assetForCompanyA->assigned_to, 'Asset should not be assigned before attempting this test case.'); - $this->assertNull($assetForCompanyB->assigned_to, 'Asset should not be assigned before attempting this test case.'); - - // create a user for one company - $userInCompanyA = User::factory()->for($companyA)->create(); - - // create a super admin and act as them - $admin = User::factory()->superuser()->create(); - - // attempt to bulk checkout both items to the user in the company - $response = $this->actingAs($admin) - ->post(route('hardware.bulkcheckout.store'), [ - 'selected_assets' => [ - $assetForCompanyA->id, - $assetForCompanyB->id, - ], - 'checkout_to_type' => 'user', - 'assigned_user' => $userInCompanyA->id, - ]); - - // ensure bulk checkout is blocked - $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); - $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); - - // ensure redirected back - $response->assertRedirectToRoute('hardware.bulkcheckout.show'); + yield 'Checkout to location' => [ + function () { + return [ + 'type' => 'location', + 'target' => Location::factory()->forCompany()->create(), + ]; + } + ]; } - public function test_adheres_to_full_multiple_company_support_when_checking_out_to_asset() + #[DataProvider('checkoutTargets')] + public function test_adheres_to_full_multiple_company_support_when_checking_out_to_user($data) { + ['type' => $type, 'target' => $target] = $data(); + $this->settings->enableMultipleFullCompanySupport(); // create two companies @@ -145,60 +140,15 @@ class BulkAssetCheckoutTest extends TestCase $this->assertNull($assetForCompanyA->assigned_to, 'Asset should not be assigned before attempting this test case.'); $this->assertNull($assetForCompanyB->assigned_to, 'Asset should not be assigned before attempting this test case.'); - // create an asset for one company - $targetAssetForCompanyA = Asset::factory()->for($companyA)->create(); - - // create a super admin and act as them - $admin = User::factory()->superuser()->create(); - - // attempt to bulk checkout both items to the user in the company - $response = $this->actingAs($admin) + // attempt to bulk checkout both items to the target + $response = $this->actingAs(User::factory()->superuser()->create()) ->post(route('hardware.bulkcheckout.store'), [ 'selected_assets' => [ $assetForCompanyA->id, $assetForCompanyB->id, ], - 'checkout_to_type' => 'asset', - 'assigned_asset' => $targetAssetForCompanyA->id, - ]); - - // ensure bulk checkout is blocked - $this->assertNull($assetForCompanyA->fresh()->assigned_to, 'Asset was checked out across companies.'); - $this->assertNull($assetForCompanyB->fresh()->assigned_to, 'Asset was checked out across companies.'); - - // ensure redirected back - $response->assertRedirectToRoute('hardware.bulkcheckout.show'); - } - - public function test_adheres_to_full_multiple_company_support_when_checking_out_to_location() - { - $this->settings->enableMultipleFullCompanySupport(); - - // create two companies - [$companyA, $companyB] = Company::factory()->count(2)->create(); - - // create an asset for each company - $assetForCompanyA = Asset::factory()->for($companyA)->create(); - $assetForCompanyB = Asset::factory()->for($companyB)->create(); - - $this->assertNull($assetForCompanyA->assigned_to, 'Asset should not be assigned before attempting this test case.'); - $this->assertNull($assetForCompanyB->assigned_to, 'Asset should not be assigned before attempting this test case.'); - - // create a location for one company - $locationForCompanyA = Location::factory()->for($companyA)->create(); - - // create a super admin and act as them - $admin = User::factory()->superuser()->create(); - - // attempt to bulk checkout both items to the user in the company - $response = $this->actingAs($admin) - ->post(route('hardware.bulkcheckout.store'), [ - 'selected_assets' => [ - $assetForCompanyA->id, - $assetForCompanyB->id, - ], - 'checkout_to_type' => 'location', - 'assigned_location' => $locationForCompanyA->id, + 'checkout_to_type' => $type, + "assigned_$type" => $target->id, ]); // ensure bulk checkout is blocked From 2dc11a84bfeb5a39fba7418e1683dc8bf92677a6 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Sep 2025 17:05:08 -0700 Subject: [PATCH 13/13] Fix test name --- tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php index f9b9398bd2..8750087394 100644 --- a/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/BulkAssetCheckoutTest.php @@ -124,7 +124,7 @@ class BulkAssetCheckoutTest extends TestCase } #[DataProvider('checkoutTargets')] - public function test_adheres_to_full_multiple_company_support_when_checking_out_to_user($data) + public function test_adheres_to_full_multiple_company_support($data) { ['type' => $type, 'target' => $target] = $data();