2024-10-21 12:01:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\Back;
|
|
|
|
|
|
|
|
|
|
use App\Enums\Users\RoleEnum;
|
|
|
|
|
use App\Models\ActivityLog;
|
|
|
|
|
use App\Models\User as AuthModel;
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
class ActivityLogTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* TESTS GUEST CANNOT ACCESS VIEWS.
|
|
|
|
|
*/
|
2026-09-25 16:25:31 +02:00
|
|
|
public function test_guest_cannot_access_activity_logs_index_view(): void
|
2024-10-21 12:01:23 +02:00
|
|
|
{
|
|
|
|
|
$response = $this->get(route(
|
|
|
|
|
config('unit-tests.route.prefix') .
|
|
|
|
|
'activity_logs.' .
|
|
|
|
|
config('unit-tests.view.resources-index')
|
|
|
|
|
));
|
|
|
|
|
$response->assertRedirect(route(config('unit-tests.route.prefix') . 'login'));
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-25 16:25:31 +02:00
|
|
|
public function test_guest_cannot_access_activity_logs_read_view(): void
|
2024-10-21 12:01:23 +02:00
|
|
|
{
|
|
|
|
|
$model = ActivityLog::factory()->createOneQuietly();
|
|
|
|
|
$response = $this->get(route(
|
|
|
|
|
config('unit-tests.route.prefix') .
|
|
|
|
|
'activity_logs.' .
|
|
|
|
|
config('unit-tests.view.resources-read'),
|
|
|
|
|
$model->getKey()
|
|
|
|
|
));
|
|
|
|
|
$response->assertRedirect(route(config('unit-tests.route.prefix') . 'login'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TESTS USER CONCEPTOR ACCESS VIEWS.
|
|
|
|
|
*/
|
2026-09-25 16:25:31 +02:00
|
|
|
public function test_user_conceptor_can_access_activity_logs_index_view(): void
|
2024-10-21 12:01:23 +02:00
|
|
|
{
|
|
|
|
|
$authModel = AuthModel::factory()->createOneQuietly();
|
|
|
|
|
$authModel->update(['role' => RoleEnum::conceptor]);
|
|
|
|
|
$response = $this->actingAs($authModel, 'backend')->get(
|
|
|
|
|
route(config('unit-tests.route.prefix') . 'activity_logs.' . config('unit-tests.view.resources-index'))
|
|
|
|
|
);
|
|
|
|
|
$response->assertSuccessful();
|
|
|
|
|
$response->assertViewIs(
|
|
|
|
|
config('unit-tests.view.prefix') .
|
|
|
|
|
'pages.activity_logs.' .
|
|
|
|
|
config('unit-tests.view.resources-index')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-25 16:25:31 +02:00
|
|
|
public function test_user_conceptor_can_access_activity_logs_read_view(): void
|
2024-10-21 12:01:23 +02:00
|
|
|
{
|
|
|
|
|
$authModel = AuthModel::factory()->createOneQuietly();
|
|
|
|
|
$authModel->update(['role' => RoleEnum::conceptor]);
|
|
|
|
|
$model = ActivityLog::factory()->createOneQuietly();
|
|
|
|
|
$response = $this->actingAs($authModel, 'backend')->get(
|
|
|
|
|
route(config('unit-tests.route.prefix') . 'activity_logs.' . config('unit-tests.view.resources-read'), $model)
|
|
|
|
|
);
|
|
|
|
|
$response->assertSuccessful();
|
|
|
|
|
$response->assertViewIs(
|
|
|
|
|
config('unit-tests.view.prefix') .
|
|
|
|
|
'pages.activity_logs.' .
|
|
|
|
|
config('unit-tests.view.resources-read')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|