snipe-it/tests/Feature/Api/Users/UsersUpdateTest.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2023-08-30 17:10:50 -07:00
<?php
namespace Tests\Feature\Api\Users;
use App\Models\Department;
use App\Models\User;
use Tests\Support\InteractsWithSettings;
use Tests\TestCase;
class UsersUpdateTest extends TestCase
{
use InteractsWithSettings;
2023-08-30 17:33:23 -07:00
public function testCanUpdateUserViaPatch()
{
$this->markTestIncomplete();
}
public function testCanUpdateUserViaPut()
{
$this->markTestIncomplete();
}
public function testDepartmentPatching()
2023-08-30 17:10:50 -07:00
{
$admin = User::factory()->superuser()->create();
$user = User::factory()->forDepartment(['name' => 'Department A'])->create();
$department = Department::factory()->create();
$this->actingAsForApi($admin)->patch(route('api.users.update', $user), [
2023-08-30 17:33:23 -07:00
// This isn't valid but doesn't return an error
'department_id' => ['id' => $department->id],
// This is the correct syntax
// 'department_id' => $department->id,
2023-08-30 17:10:50 -07:00
])->assertOk();
$this->assertTrue(
$user->fresh()->department()->is($department),
'User is not associated with expected department'
);
}
}