mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Location test additions
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
7455bf329d
commit
97775fb790
|
@ -6,24 +6,30 @@ use App\Models\Location;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class UpdateLocationsTest extends TestCase
|
class CreateLocationsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testCanUpdateLocationViaPatchWithoutLocationType()
|
public function testRequiresPermissionToCreateLocation()
|
||||||
|
{
|
||||||
|
$this->actingAsForApi(User::factory()->create())
|
||||||
|
->postJson(route('api.departments.store'))
|
||||||
|
->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCannotCreateNewLocationsWithTheSameName()
|
||||||
{
|
{
|
||||||
$location = Location::factory()->create();
|
$location = Location::factory()->create();
|
||||||
|
$location2 = Location::factory()->create();
|
||||||
|
|
||||||
$this->actingAsForApi(User::factory()->superuser()->create())
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
->patchJson(route('api.locations.update', $location), [
|
->patchJson(route('api.locations.update', $location2), [
|
||||||
'name' => 'Test Location',
|
'name' => $location->name,
|
||||||
])
|
])
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertStatusMessageIs('success')
|
->assertStatusMessageIs('error')
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->json();
|
->json();
|
||||||
|
|
||||||
$location->refresh();
|
|
||||||
$this->assertEquals('Test Location', $location->name, 'Name was not updated');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
38
tests/Feature/Locations/Api/UpdateLocationsTest.php
Normal file
38
tests/Feature/Locations/Api/UpdateLocationsTest.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Locations\Api;
|
||||||
|
|
||||||
|
use App\Models\Location;
|
||||||
|
use App\Models\User;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class UpdateLocationsTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testRequiresPermissionToEditLocation()
|
||||||
|
{
|
||||||
|
$this->actingAsForApi(User::factory()->create())
|
||||||
|
->postJson(route('api.locations.store', Location::factory()->create()))
|
||||||
|
->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCanUpdateLocationViaPatch()
|
||||||
|
{
|
||||||
|
$location = Location::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
->patchJson(route('api.locations.update', $location), [
|
||||||
|
'name' => 'Test Location',
|
||||||
|
])
|
||||||
|
->assertOk()
|
||||||
|
->assertStatusMessageIs('success')
|
||||||
|
->assertStatus(200)
|
||||||
|
->json();
|
||||||
|
|
||||||
|
$location->refresh();
|
||||||
|
$this->assertEquals('Test Location', $location->name, 'Name was not updated');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue