snipe-it/tests/Feature/Locations/Api/CreateLocationsTest.php
snipe 97775fb790 Location test additions
Signed-off-by: snipe <snipe@snipe.net>
2024-07-05 08:29:00 +01:00

37 lines
887 B
PHP

<?php
namespace Tests\Feature\Locations\Api;
use App\Models\Location;
use App\Models\User;
use Tests\TestCase;
class CreateLocationsTest extends TestCase
{
public function testRequiresPermissionToCreateLocation()
{
$this->actingAsForApi(User::factory()->create())
->postJson(route('api.departments.store'))
->assertForbidden();
}
public function testCannotCreateNewLocationsWithTheSameName()
{
$location = Location::factory()->create();
$location2 = Location::factory()->create();
$this->actingAsForApi(User::factory()->superuser()->create())
->patchJson(route('api.locations.update', $location2), [
'name' => $location->name,
])
->assertOk()
->assertStatusMessageIs('error')
->assertStatus(200)
->json();
}
}