@@ -143,14 +143,34 @@ public function test_can_checkout_to_user_with_multiple_companies_via_pivot_when
143143 Event::assertDispatched (CheckoutableCheckedOut::class);
144144 }
145145
146- public function test_can_checkout_to_child_location_whose_parent_has_matching_company_when_fmcs_enabled ()
146+ public function test_can_checkout_to_uncompanied_location_when_fmcs_enabled_without_location_scoping ()
147147 {
148148 $ this ->settings ->enableMultipleFullCompanySupport ();
149149
150+ $ company = Company::factory ()->create ();
151+ $ location = Location::factory ()->create (['company_id ' => null ]);
152+ $ asset = Asset::factory ()->for ($ company )->create ();
153+
154+ $ this ->actingAs (User::factory ()->superuser ()->create ())
155+ ->post (route ('hardware.checkout.store ' , $ asset ), [
156+ 'checkout_to_type ' => 'location ' ,
157+ 'assigned_location ' => $ location ->id ,
158+ 'redirect_option ' => 'index ' ,
159+ ])
160+ ->assertSessionMissing ('error ' )
161+ ->assertRedirect ();
162+
163+ Event::assertDispatched (CheckoutableCheckedOut::class);
164+ }
165+
166+ public function test_can_checkout_to_child_location_whose_parent_has_matching_company_when_location_scoping_enabled ()
167+ {
168+ $ this ->settings ->enableScopedLocationsWithFullMultipleCompanySupport ();
169+
150170 $ company = Company::factory ()->create ();
151171 $ parentLocation = Location::factory ()->for ($ company )->create ();
152172 $ childLocation = Location::factory ()->create (['parent_id ' => $ parentLocation ->id , 'company_id ' => null ]);
153- $ asset = Asset::factory ()->for ($ company )->create ();
173+ $ asset = Asset::factory ()->for ($ company )->create ([ ' rtd_location_id ' => $ parentLocation -> id ] );
154174
155175 $ this ->actingAs (User::factory ()->superuser ()->create ())
156176 ->post (route ('hardware.checkout.store ' , $ asset ), [
@@ -164,15 +184,15 @@ public function test_can_checkout_to_child_location_whose_parent_has_matching_co
164184 Event::assertDispatched (CheckoutableCheckedOut::class);
165185 }
166186
167- public function test_cannot_checkout_to_child_location_whose_parent_has_different_company_when_fmcs_enabled ()
187+ public function test_cannot_checkout_to_child_location_whose_parent_has_different_company_when_location_scoping_enabled ()
168188 {
169- $ this ->settings ->enableMultipleFullCompanySupport ();
189+ $ this ->settings ->enableScopedLocationsWithFullMultipleCompanySupport ();
170190
171191 $ assetCompany = Company::factory ()->create ();
172192 $ otherCompany = Company::factory ()->create ();
173193 $ parentLocation = Location::factory ()->for ($ otherCompany )->create ();
174194 $ childLocation = Location::factory ()->create (['parent_id ' => $ parentLocation ->id , 'company_id ' => null ]);
175- $ asset = Asset::factory ()->for ($ assetCompany )->create ();
195+ $ asset = Asset::factory ()->for ($ assetCompany )->create ([ ' rtd_location_id ' => null ] );
176196
177197 $ this ->actingAs (User::factory ()->superuser ()->create ())
178198 ->post (route ('hardware.checkout.store ' , $ asset ), [
0 commit comments