Files
UNIT3D-Community-Edition/tests/Feature/Http/Controllers/Staff/UserControllerTest.php
2023-07-11 18:27:15 +00:00

93 lines
3.2 KiB
PHP

<?php
uses(RefreshDatabase::class);
test('edit returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$user = \App\Models\User::factory()->create();
$groups = \App\Models\Group::factory()->times(3)->create();
$internals = \App\Models\Internal::factory()->times(3)->create();
$authUser = \App\Models\User::factory()->create();
$response = $this->actingAs($authUser)->get(route('staff.users.edit', [$user]));
$response->assertOk();
$response->assertViewIs('Staff.user.edit');
$response->assertViewHas('user', $user);
$response->assertViewHas('groups', $groups);
$response->assertViewHas('internals', $internals);
// TODO: perform additional assertions
});
test('index returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('staff.users.index'));
$response->assertOk();
$response->assertViewIs('Staff.user.index');
// TODO: perform additional assertions
});
test('permissions returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$user = \App\Models\User::factory()->create();
$authUser = \App\Models\User::factory()->create();
$response = $this->actingAs($authUser)->patch(route('staff.users.update_permissions', [$user]), [
// TODO: send request data
]);
$response->assertOk();
// TODO: perform additional assertions
});
test('update validates with a form request', function (): void {
$this->assertActionUsesFormRequest(
\App\Http\Controllers\Staff\UserController::class,
'update',
\App\Http\Requests\Staff\UpdateUserRequest::class
);
});
test('update returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$user = \App\Models\User::factory()->create();
$group = \App\Models\Group::factory()->create();
$authUser = \App\Models\User::factory()->create();
$response = $this->actingAs($authUser)->patch(route('staff.users.update', [$user]), [
// TODO: send request data
]);
$response->assertOk();
// TODO: perform additional assertions
});
test('update aborts with a 403', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$user = \App\Models\User::factory()->create();
$group = \App\Models\Group::factory()->create();
$authUser = \App\Models\User::factory()->create();
// TODO: perform additional setup to trigger `abort_if(403)`...
$response = $this->actingAs($authUser)->patch(route('staff.users.update', [$user]), [
// TODO: send request data
]);
$response->assertForbidden();
});
// test cases...