优化手机输入及钓鱼
This commit is contained in:
@@ -5,10 +5,12 @@ namespace Tests\Feature;
|
||||
use App\Models\Room;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -195,6 +197,24 @@ class ChatControllerTest extends TestCase
|
||||
Storage::disk('public')->assertExists($payload['image_thumb_path']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试聊天室发送接口在 419 场景下会返回稳定的 JSON 提示。
|
||||
*/
|
||||
public function test_chat_send_http_419_exception_renders_json_response(): void
|
||||
{
|
||||
$request = Request::create('/room/1/send', 'POST', server: [
|
||||
'HTTP_ACCEPT' => 'application/json',
|
||||
]);
|
||||
|
||||
$response = $this->app->make(\Illuminate\Contracts\Debug\ExceptionHandler::class)
|
||||
->render($request, new HttpException(419, 'Page Expired'));
|
||||
|
||||
\Illuminate\Testing\TestResponse::fromBaseResponse($response)->assertStatus(419)->assertJson([
|
||||
'status' => 'error',
|
||||
'message' => '页面已过期,请刷新后重试。',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试超过保留期的聊天图片会被命令清理并改成过期占位消息。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user