Populate failing test

This commit is contained in:
Marcus Moore
2025-09-17 13:49:32 -07:00
parent 89cfafd933
commit d2157868f2
@@ -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.');
}
}