ResponseTest.php 817 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Illuminate\Tests\Integration\Http;
  3. use Illuminate\Http\Response;
  4. use Illuminate\Support\Facades\Route;
  5. use Orchestra\Testbench\TestCase;
  6. class ResponseTest extends TestCase
  7. {
  8. public function testResponseWithInvalidJsonThrowsException()
  9. {
  10. $this->expectException('InvalidArgumentException');
  11. $this->expectExceptionMessage('Malformed UTF-8 characters, possibly incorrectly encoded');
  12. Route::get('/response', function () {
  13. return (new Response())->setContent(new class implements \JsonSerializable
  14. {
  15. public function jsonSerialize(): string
  16. {
  17. return "\xB1\x31";
  18. }
  19. });
  20. });
  21. $this->withoutExceptionHandling();
  22. $this->get('/response');
  23. }
  24. }