diff --git a/tests/Feature/Locations/Api/LocationsViewTest.php b/tests/Feature/Locations/Api/LocationsViewTest.php index 9f564a6f0..cec020d1c 100644 --- a/tests/Feature/Locations/Api/LocationsViewTest.php +++ b/tests/Feature/Locations/Api/LocationsViewTest.php @@ -28,7 +28,7 @@ class LocationsViewTest extends TestCase public function testViewingLocationAssetIndex() { $location = Location::factory()->create(); - Asset::factory()->count(3)->assignedToLocation($location)->create(); + Asset::factory()->count(3)->create(['location_id' => $location->id]); $this->actingAsForApi(User::factory()->superuser()->create()) ->getJson(route('api.locations.viewassets', $location->id)) @@ -41,4 +41,21 @@ class LocationsViewTest extends TestCase 'total' => 3, ]); } + + public function testViewingAssignedLocationAssetIndex() + { + $location = Location::factory()->create(); + Asset::factory()->count(3)->assignedToLocation($location)->create(); + + $this->actingAsForApi(User::factory()->superuser()->create()) + ->getJson(route('api.locations.assigned_assets', $location->id)) + ->assertOk() + ->assertJsonStructure([ + 'total', + 'rows', + ]) + ->assertJson([ + 'total' => 3, + ]); + } }