A free open source IT asset/license management system
Add failing test
Marcus Moore1714d627621b
diff --git a/tests/Feature/Assets/Ui/StoreAssetWithFullMultipleCompanySupportTest.php b/tests/Feature/Assets/Ui/StoreAssetWithFullMultipleCompanySupportTest.phpindex c11142bcdf..695393a276 100644--- a/tests/Feature/Assets/Ui/StoreAssetWithFullMultipleCompanySupportTest.php+++ b/tests/Feature/Assets/Ui/StoreAssetWithFullMultipleCompanySupportTest.php@@ -4,7 +4,10 @@ namespace Tests\Feature\Assets\Ui;use App\Models\Asset;use App\Models\AssetModel;+use App\Models\Company;+use App\Models\Location;use App\Models\Statuslabel;+use App\Models\User;use PHPUnit\Framework\Attributes\DataProvider;use Tests\Support\ProvidesDataForFullMultipleCompanySupportTesting;use Tests\TestCase;@@ -32,4 +35,48 @@ class StoreAssetWithFullMultipleCompanySupportTest extends TestCase$assertions($asset);}++ /**+ * @link https://github.com/grokability/snipe-it/issues/18798+ */+ public function test_allows_creating_asset_with_scoped_location()+ {+ $this->settings->enableScopedLocationsWithFullMultipleCompanySupport();++ $company = Company::factory()->create();+ $location = Location::factory()->for($company)->create();++ $admin = User::factory()->admin()->for($company)->create();++ $this->actingAs($admin)+ ->post(route('hardware.store'), [+ 'asset_tags' => ['1' => '1234'],+ 'serials' => ['1' => null],+ 'model_id' => AssetModel::factory()->create()->id,+ 'status_id' => Statuslabel::factory()->readyToDeploy()->create()->id,+ 'checkout_to_type' => 'user',+ 'assigned_user' => $admin->id,+ 'assigned_asset' => null,+ 'notes' => null,+ 'rtd_location_id' => $location->id,+ 'name' => null,+ 'warranty_months' => null,+ 'expected_checkin' => null,+ 'next_audit_date' => null,+ 'order_number' => null,+ 'purchase_date' => null,+ 'asset_eol_date' => null,+ 'purchase_cost' => null,+ 'redirect_option' => 'back',+ ])->assertSessionHasNoErrors();++ $asset = Asset::where(['asset_tag' => '1234'])->first();++ if (! $asset->exists()) {+ $this->fail('Asset was not created.');+ }++ $this->assertEquals($location->id, $asset->location_id);+ $this->assertEquals($admin->id, $asset->assigned_to);+ }}diff --git a/tests/Support/Settings.php b/tests/Support/Settings.phpindex 6620d4c69d..fff2a79f63 100644--- a/tests/Support/Settings.php+++ b/tests/Support/Settings.php@@ -94,6 +94,14 @@ class Settingsreturn $this->update(['full_multiple_companies_support' => 0]);}+ public function enableScopedLocationsWithFullMultipleCompanySupport(): Settings+ {+ $this->update(['full_multiple_companies_support' => 1]);+ $this->update(['scope_locations_fmcs' => 1]);++ return $this;+ }+public function enableSlackWebhook(): Settings{return $this->update([