mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 05:47:28 -08:00
Added tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
4d03f1e110
commit
a23dee52f2
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue