/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Http/JsonResponseTest.php
50 строк
1 KB
Lucas Michot
[13.x] Simplify most of the exceptions expectations (#61049)
05 авг 2026, 18:34
Не верифицирован
05 авг 2026, 18:34
910cd94
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Http; use Illuminate\Contracts\Support\Jsonable; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Route; use InvalidArgumentException; use JsonSerializable; use Orchestra\Testbench\TestCase; class JsonResponseTest extends TestCase { public function testResponseWithInvalidJsonThrowsException() { $this->expectExceptionObject(new InvalidArgumentException('Malformed UTF-8 characters, possibly incorrectly encoded')); Route::get('/response', function () { return new JsonResponse(new class implements JsonSerializable { public function jsonSerialize(): string { return "\xB1\x31"; } }); }); $this->withoutExceptionHandling(); $this->get('/response'); } public function testResponseSetDataPassesWithPriorJsonErrors() { $response = new JsonResponse(); // Trigger json_last_error() to have a non-zero value... json_encode(['a' => acos(2)]); $response->setData(new class implements Jsonable { public function toJson($options = 0): string { return '{}'; } }); $this->assertJson($response->getContent()); } }