Skip to content

A free open source IT asset/license management system

Add failing test

Marcus Moore374812f8fe96
diff --git a/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php b/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
index da285bebbb..601eeb0b55 100644
--- a/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
+++ b/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
@@ -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]));
}
-
-
}