snipe-it/tests/Feature/Departments/Api/UpdateDepartmentTest.php
snipe 0a7e053985 Added basic Department UI tests
Signed-off-by: snipe <snipe@snipe.net>
2024-07-05 07:53:02 +01:00

42 lines
1 KiB
PHP

<?php
namespace Tests\Feature\Departments\Api;
use App\Models\Department;
use App\Models\Category;
use App\Models\User;
use Tests\TestCase;
class UpdateDepartmentsTest extends TestCase
{
public function testRequiresPermissionToEditDepartment()
{
$department = Department::factory()->create();
$this->actingAsForApi(User::factory()->create())
->patchJson(route('api.departments.update', $department))
->assertForbidden();
}
public function testCanUpdateDepartmentViaPatch()
{
$department = Department::factory()->create();
$this->actingAsForApi(User::factory()->superuser()->create())
->patchJson(route('api.departments.update', $department), [
'name' => 'Test Department',
])
->assertOk()
->assertStatusMessageIs('success')
->assertStatus(200)
->json();
$department->refresh();
$this->assertEquals('Test Department', $department->name, 'Name was not updated');
}
}