3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-04-03 22:38:31 +00:00
Files
snipe-it/tests/Feature/Locations/Api/UpdateLocationsTest.php
2026-03-16 17:40:57 -07:00

37 lines
1.1 KiB
PHP

<?php
namespace Tests\Feature\Locations\Api;
use App\Models\Location;
use App\Models\User;
use Tests\TestCase;
class UpdateLocationsTest extends TestCase
{
public function test_requires_permission_to_edit_location()
{
$this->actingAsForApi(User::factory()->create())
->patchJson(route('api.locations.update', Location::factory()->create()))
->assertForbidden();
}
public function test_can_update_location_via_patch()
{
$location = Location::factory()->create();
$this->actingAsForApi(User::factory()->superuser()->create())
->patchJson(route('api.locations.update', $location), [
'name' => 'Test Updated Location',
'notes' => 'Test Updated Note',
])
->assertOk()
->assertStatusMessageIs('success')
->assertStatus(200)
->json();
$location->refresh();
$this->assertEquals('Test Updated Location', $location->name, 'Name was not updated');
$this->assertEquals('Test Updated Note', $location->notes, 'Note was not updated');
}
}