Add failing test

This commit is contained in:
Marcus Moore 2024-08-06 10:48:38 -07:00
parent b83d148b37
commit 374812f8fe
No known key found for this signature in database

View file

@ -1,10 +1,13 @@
<?php
namespace Tests\Feature\Checkins\Ui;
namespace Tests\Feature\Checkouts\Ui;
use App\Events\CheckoutableCheckedOut;
use App\Models\Asset;
use App\Models\Company;
use App\Models\Component;
use App\Models\User;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
class ComponentsCheckoutTest extends TestCase
@ -18,6 +21,30 @@ class ComponentsCheckoutTest extends TestCase
->assertForbidden();
}
public function testCannotCheckoutAcrossCompaniesWhenFullCompanySupportEnabled()
{
Event::fake([CheckoutableCheckedOut::class]);
$this->settings->enableMultipleFullCompanySupport();
[$assetCompany, $componentCompany] = Company::factory()->count(2)->create();
$asset = Asset::factory()->for($assetCompany)->create();
$component = Component::factory()->for($componentCompany)->create();
$this->actingAs(User::factory()->superuser()->create())
->post(route('components.checkout.store', $component), [
'asset_id' => $asset->id,
'assigned_qty' => '1',
// @todo:
'note' => null,
// @todo:
'redirect_option' => 'index',
]);
Event::assertNotDispatched(CheckoutableCheckedOut::class);
}
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
{
$component = Component::factory()->create();
@ -63,6 +90,4 @@ class ComponentsCheckoutTest extends TestCase
->assertStatus(302)
->assertRedirect(route('hardware.show', ['hardware' => $asset]));
}
}