<?php

declare(strict_types=1);

namespace Tests\Feature;

use App\Models\Answer;
use App\Models\Category;
use App\Models\Log;
use App\Models\Question;
use App\Models\QuestionGroup;
use App\Models\Screening;
use App\Models\Session;
use App\Models\User;
use App\Policies\AnswerPolicy;
use App\Policies\CategoryPolicy;
use App\Policies\LogPolicy;
use App\Policies\QuestionGroupPolicy;
use App\Policies\QuestionPolicy;
use App\Policies\ScreeningPolicy;
use App\Policies\SessionPolicy;
use Tests\TestCase;

class PolicyTest extends TestCase
{
    public function test_category_policy_allows_view_any(): void
    {
        $user = User::factory()->create();
        $policy = new CategoryPolicy;

        $this->assertTrue($policy->viewAny($user));
    }

    public function test_category_policy_allows_view(): void
    {
        $user = User::factory()->create();
        $category = Category::factory()->create();
        $policy = new CategoryPolicy;

        $this->assertTrue($policy->view($user, $category));
    }

    public function test_category_policy_denies_create(): void
    {
        $user = User::factory()->create();
        $policy = new CategoryPolicy;

        $this->assertFalse($policy->create($user));
    }

    public function test_category_policy_denies_update(): void
    {
        $user = User::factory()->create();
        $category = Category::factory()->create();
        $policy = new CategoryPolicy;

        $this->assertFalse($policy->update($user, $category));
    }

    public function test_category_policy_denies_delete(): void
    {
        $user = User::factory()->create();
        $category = Category::factory()->create();
        $policy = new CategoryPolicy;

        $this->assertFalse($policy->delete($user, $category));
    }

    public function test_question_group_policy_allows_view_any(): void
    {
        $user = User::factory()->create();
        $policy = new QuestionGroupPolicy;

        $this->assertTrue($policy->viewAny($user));
    }

    public function test_question_group_policy_allows_view(): void
    {
        $user = User::factory()->create();
        $questionGroup = QuestionGroup::factory()->create();
        $policy = new QuestionGroupPolicy;

        $this->assertTrue($policy->view($user, $questionGroup));
    }

    public function test_question_group_policy_denies_create(): void
    {
        $user = User::factory()->create();
        $policy = new QuestionGroupPolicy;

        $this->assertFalse($policy->create($user));
    }

    public function test_question_group_policy_denies_update(): void
    {
        $user = User::factory()->create();
        $questionGroup = QuestionGroup::factory()->create();
        $policy = new QuestionGroupPolicy;

        $this->assertFalse($policy->update($user, $questionGroup));
    }

    public function test_question_group_policy_denies_delete(): void
    {
        $user = User::factory()->create();
        $questionGroup = QuestionGroup::factory()->create();
        $policy = new QuestionGroupPolicy;

        $this->assertFalse($policy->delete($user, $questionGroup));
    }

    public function test_question_policy_allows_view_any(): void
    {
        $user = User::factory()->create();
        $policy = new QuestionPolicy;

        $this->assertTrue($policy->viewAny($user));
    }

    public function test_question_policy_allows_view(): void
    {
        $user = User::factory()->create();
        $question = Question::factory()->create();
        $policy = new QuestionPolicy;

        $this->assertTrue($policy->view($user, $question));
    }

    public function test_question_policy_denies_create(): void
    {
        $user = User::factory()->create();
        $policy = new QuestionPolicy;

        $this->assertFalse($policy->create($user));
    }

    public function test_question_policy_allows_update(): void
    {
        $user = User::factory()->create();
        $question = Question::factory()->create();
        $policy = new QuestionPolicy;

        $this->assertTrue($policy->update($user, $question));
    }

    public function test_question_policy_denies_delete(): void
    {
        $user = User::factory()->create();
        $question = Question::factory()->create();
        $policy = new QuestionPolicy;

        $this->assertFalse($policy->delete($user, $question));
    }

    public function test_screening_policy_allows_view_any(): void
    {
        $user = User::factory()->create();
        $policy = new ScreeningPolicy;

        $this->assertTrue($policy->viewAny($user));
    }

    public function test_screening_policy_allows_view(): void
    {
        $user = User::factory()->create();
        $screening = Screening::factory()->create();
        $policy = new ScreeningPolicy;

        $this->assertTrue($policy->view($user, $screening));
    }

    public function test_screening_policy_denies_create(): void
    {
        $user = User::factory()->create();
        $policy = new ScreeningPolicy;

        $this->assertFalse($policy->create($user));
    }

    public function test_screening_policy_denies_update(): void
    {
        $user = User::factory()->create();
        $screening = Screening::factory()->create();
        $policy = new ScreeningPolicy;

        $this->assertFalse($policy->update($user, $screening));
    }

    public function test_screening_policy_denies_delete(): void
    {
        $user = User::factory()->create();
        $screening = Screening::factory()->create();
        $policy = new ScreeningPolicy;

        $this->assertFalse($policy->delete($user, $screening));
    }

    public function test_session_policy_allows_view_any(): void
    {
        $user = User::factory()->create();
        $policy = new SessionPolicy;

        $this->assertTrue($policy->viewAny($user));
    }

    public function test_session_policy_allows_view(): void
    {
        $user = User::factory()->create();
        $session = Session::factory()->create();
        $policy = new SessionPolicy;

        $this->assertTrue($policy->view($user, $session));
    }

    public function test_session_policy_denies_create(): void
    {
        $user = User::factory()->create();
        $policy = new SessionPolicy;

        $this->assertFalse($policy->create($user));
    }

    public function test_session_policy_denies_update(): void
    {
        $user = User::factory()->create();
        $session = Session::factory()->create();
        $policy = new SessionPolicy;

        $this->assertFalse($policy->update($user, $session));
    }

    public function test_session_policy_denies_delete(): void
    {
        $user = User::factory()->create();
        $session = Session::factory()->create();
        $policy = new SessionPolicy;

        $this->assertFalse($policy->delete($user, $session));
    }

    public function test_answer_policy_allows_view_any(): void
    {
        $user = User::factory()->create();
        $policy = new AnswerPolicy;

        $this->assertTrue($policy->viewAny($user));
    }

    public function test_answer_policy_allows_view(): void
    {
        $user = User::factory()->create();
        $answer = Answer::factory()->create();
        $policy = new AnswerPolicy;

        $this->assertTrue($policy->view($user, $answer));
    }

    public function test_answer_policy_denies_create(): void
    {
        $user = User::factory()->create();
        $policy = new AnswerPolicy;

        $this->assertFalse($policy->create($user));
    }

    public function test_answer_policy_denies_update(): void
    {
        $user = User::factory()->create();
        $answer = Answer::factory()->create();
        $policy = new AnswerPolicy;

        $this->assertFalse($policy->update($user, $answer));
    }

    public function test_answer_policy_denies_delete(): void
    {
        $user = User::factory()->create();
        $answer = Answer::factory()->create();
        $policy = new AnswerPolicy;

        $this->assertFalse($policy->delete($user, $answer));
    }

    public function test_log_policy_allows_view_any(): void
    {
        $user = User::factory()->create();
        $policy = new LogPolicy;

        $this->assertTrue($policy->viewAny($user));
    }

    public function test_log_policy_allows_view(): void
    {
        $user = User::factory()->create();
        $log = Log::factory()->create();
        $policy = new LogPolicy;

        $this->assertTrue($policy->view($user, $log));
    }

    public function test_log_policy_denies_create(): void
    {
        $user = User::factory()->create();
        $policy = new LogPolicy;

        $this->assertFalse($policy->create($user));
    }

    public function test_log_policy_denies_update(): void
    {
        $user = User::factory()->create();
        $log = Log::factory()->create();
        $policy = new LogPolicy;

        $this->assertFalse($policy->update($user, $log));
    }

    public function test_log_policy_denies_delete(): void
    {
        $user = User::factory()->create();
        $log = Log::factory()->create();
        $policy = new LogPolicy;

        $this->assertFalse($policy->delete($user, $log));
    }
}
