Skip to content

Commit

Permalink
Adding Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ModestasV committed Sep 2, 2024
1 parent 420a162 commit 01f4caf
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/Feature/UserTaskTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use App\Models\User;
use App\Models\Task;
use function Pest\Laravel\actingAs;

it('allows users to access tasks page', function () {
$user = User::factory()->create();

actingAs($user)
->get(route('user.tasks.index'))
->assertOk();
});

it('does not allow users to access admin task page', function () {
$user = User::factory()->create();

actingAs($user)
->get(route('admin.tasks.index'))
->assertForbidden();
});

it('allows administrator to access tasks page', function () {
$user = User::factory()->create(['is_admin' => true]);

actingAs($user)
->get(route('admin.tasks.index'))
->assertOk();
});

0 comments on commit 01f4caf

Please sign in to comment.