Skip to content

A free open source IT asset/license management system

Populate failing test

Marcus Moored2157868f2b4
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.');
}
}