A free open source IT asset/license management system
Added tests
snipea23dee52f27a
diff --git a/tests/Feature/Locations/Ui/CreateLocationsTest.php b/tests/Feature/Locations/Ui/CreateLocationsTest.phpindex 5e229f1043..c6813c26b8 100644--- a/tests/Feature/Locations/Ui/CreateLocationsTest.php+++ b/tests/Feature/Locations/Ui/CreateLocationsTest.php@@ -32,6 +32,19 @@ class CreateLocationsTest extends TestCase$this->assertTrue(Location::where('name', 'Test Location')->exists());}-++ public function testUserCannotCreateLocationsWithInvalidParent()+ {+ $this->assertFalse(Location::where('name', 'Test Location')->exists());++ $this->actingAs(User::factory()->superuser()->create())+ ->post(route('locations.store'), [+ 'name' => 'Test Location',+ 'parent_id' => '100000000'+ ])+ ->assertRedirect(route('locations.index'));++ $this->assertFalse(Location::where('name', 'Test Location')->exists());+ }}diff --git a/tests/Feature/Locations/Ui/UpdateLocationsTest.php b/tests/Feature/Locations/Ui/UpdateLocationsTest.phpindex 5359cd1b71..f8fa934b36 100644--- a/tests/Feature/Locations/Ui/UpdateLocationsTest.php+++ b/tests/Feature/Locations/Ui/UpdateLocationsTest.php@@ -52,6 +52,21 @@ class UpdateLocationsTest extends TestCase$this->assertFalse(Location::where('name', 'Test Location')->exists());}+ public function testUserCannotEditLocationsWithInvalidParent()+ {+ $location = Location::factory()->create();+ $response = $this->actingAs(User::factory()->superuser()->create())+ ->from(route('locations.edit', ['location' => $location->id]))+ ->put(route('locations.update', ['location' => $location]), [+ 'name' => 'Test Location',+ 'parent_id' => '100000000'+ ])+ ->assertRedirect(route('locations.index'));++ $this->followRedirects($response)->assertSee(trans('general.error'));+ $this->assertFalse(Location::where('name', 'Test Location')->exists());+ }+}