/
evo
/
docviz
Обзор
Документация
Войти
/
evo
/
docviz
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
tests/Feature/AppealTest.php
75 строк
2 KB
evo
UI updates, deployment prep, and code highlighting fix
08 фев 2026, 12:17
Верифицирован
08 фев 2026, 12:17
2c0897e
Код
Авторство
О чём код?
<?php namespace Tests\Feature; use App\Models\Appeal; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class AppealTest extends TestCase { use RefreshDatabase; public function test_appeal_create_requires_auth(): void { $response = $this->get(route('appeal.create')); $response->assertRedirect(route('login')); } public function test_banned_user_can_access_appeal_form(): void { $user = User::factory()->user()->create(); $user->update([ 'previous_role' => 'user', 'role' => 'banned', 'banned_until' => now()->addDays(7), ]); $response = $this->actingAs($user)->get(route('appeal.create')); $response->assertStatus(200); } public function test_user_can_submit_appeal(): void { $user = User::factory()->user()->create(); $user->update([ 'previous_role' => 'user', 'role' => 'banned', 'banned_until' => now()->addDays(7), ]); $response = $this->actingAs($user)->post(route('appeal.store'), [ 'message' => 'I want to appeal my ban. This is a detailed message explaining my situation and why I believe the ban should be lifted.', ]); $response->assertRedirect(); $this->assertDatabaseHas('appeals', [ 'user_id' => $user->id, 'message' => 'I want to appeal my ban. This is a detailed message explaining my situation and why I believe the ban should be lifted.', 'status' => 'pending', ]); } public function test_appeals_index_requires_moderator_role(): void { $user = User::factory()->user()->create(); $response = $this->actingAs($user)->get(route('appeals.index')); $response->assertStatus(403); } public function test_moderator_can_access_appeals_index(): void { $user = User::factory()->moderator()->create(); $response = $this->actingAs($user)->get(route('appeals.index')); $response->assertStatus(200); } public function test_moderator_can_view_appeal(): void { $moderator = User::factory()->moderator()->create(); $appeal = Appeal::factory()->pending()->create(); $response = $this->actingAs($moderator)->get(route('appeals.show', $appeal)); $response->assertStatus(200); } }