/
evo
/
docviz
Обзор
Документация
Войти
/
evo
/
docviz
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
tests/Feature/MessagingTest.php
58 строк
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\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class MessagingTest extends TestCase { use RefreshDatabase; public function test_messages_index_requires_auth(): void { $response = $this->get(route('messages.index')); $response->assertRedirect(route('login')); } public function test_user_can_access_messages(): void { $user = User::factory()->user()->create(); $response = $this->actingAs($user)->get(route('messages.index')); $response->assertStatus(200); } public function test_user_can_view_conversation(): void { $user = User::factory()->user()->create(); $other = User::factory()->user()->create(); $response = $this->actingAs($user)->get(route('messages.show', $other)); $response->assertStatus(200); } public function test_user_can_send_message(): void { $user = User::factory()->user()->create(); $other = User::factory()->user()->create(); $response = $this->actingAs($user)->post(route('messages.store', $other), [ 'content' => 'Hello, this is a test message!', ]); $response->assertRedirect(); $this->assertDatabaseHas('messages', [ 'from_user_id' => $user->id, 'to_user_id' => $other->id, 'content' => 'Hello, this is a test message!', ]); } public function test_user_can_get_unread_count(): void { $user = User::factory()->user()->create(); $response = $this->actingAs($user)->getJson(route('api.messages.unread-count')); $response->assertStatus(200); $response->assertJsonStructure(['count']); } }