Skip to content

Commit 50730fc

Browse files
committed
Add tests for delete location endpoint
1 parent 60a54ce commit 50730fc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

database/factories/UserFactory.php

+5
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ public function deleteCategories()
311311
return $this->appendPermission(['categories.delete' => '1']);
312312
}
313313

314+
public function deleteLocations()
315+
{
316+
return $this->appendPermission(['locations.delete' => '1']);
317+
}
318+
314319
public function canEditOwnLocation()
315320
{
316321
return $this->appendPermission(['self.edit_location' => '1']);

tests/Feature/Locations/Api/DeleteLocationsTest.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class DeleteLocationsTest extends TestCase
1111
{
12-
1312
public function testErrorReturnedViaApiIfLocationDoesNotExist()
1413
{
1514
$this->actingAsForApi(User::factory()->superuser()->create())
@@ -90,4 +89,15 @@ public function testDisallowUserDeletionViaApiIfStillHasAssetsAsLocation()
9089
->json();
9190
}
9291

92+
public function testCanDeleteLocation()
93+
{
94+
$location = Location::factory()->create();
95+
96+
$this->actingAsForApi(User::factory()->deleteLocations()->create())
97+
->deleteJson(route('api.locations.destroy', $location->id))
98+
->assertOk()
99+
->assertStatusMessageIs('success');
100+
101+
$this->assertSoftDeleted($location);
102+
}
93103
}

0 commit comments

Comments
 (0)