<?php

declare(strict_types=1);

use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Route;

it('renders QueryException as human JSON message, not SQLSTATE', function () {
    Route::get('/_test/boom-query', function () {
        throw new QueryException('pgsql', 'SELECT 1', [], new Exception('SQLSTATE[23505] duplicate key'));
    });

    $res = $this->getJson('/_test/boom-query');
    $res->assertStatus(422);
    expect($res->json('message'))->not->toContain('SQLSTATE');
    expect($res->json('message'))->toContain('Не удалось');
});
