1 Commits
Author SHA1 Message Date
rsgrinko bd4ad625c2 мелкие правки 2026-11-13 16:43:35 +03:00
5 changed files with 32 additions and 9 deletions

No files matched your search

+2 -1
View File
@@ -167,7 +167,8 @@ final class HttpTransport
$status = (int) curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$errno = curl_errno($ch);
$error = curl_error($ch);
curl_close($ch);
// curl_close() не нужен: с PHP 8.0 дескриптор — объект и закрывается
// сам, а в PHP 8.5 вызов объявлен устаревшим.
// 23 = CURLE_WRITE_ERROR: это мы сами оборвали слишком большой ответ.
if ($errno !== 0 && !($truncated && $errno === 23)) {
+13 -6
View File
@@ -7,6 +7,19 @@ declare(strict_types=1);
use Rsgrinko\AiSdk\Tools\DatabaseTool;
use Rsgrinko\AiSdk\Tools\Support\TextTable;
test('TextTable: кириллица выравнивается по символам', function (): void {
$table = TextTable::render([['город', 'n'], ['Тула', '1'], ['Москва', '22']]);
assertSame("город | n\n-------+---\nТула | 1\nМосква | 22", $table);
});
// Дальше нужен SQLite: без драйвера тесты пропускаются, а не падают.
if (!in_array('sqlite', PDO::getAvailableDrivers(), true)) {
skip('sql_query: 11 тестов', 'нет драйвера pdo_sqlite');
return;
}
function demoDb(): PDO
{
$pdo = new PDO('sqlite::memory:');
@@ -129,9 +142,3 @@ test('sql_query: описание зависит от режима и имени
assertContains('INSERT, UPDATE, DELETE', $full->description());
assertSame('billing_sql', $full->name());
});
test('TextTable: кириллица выравнивается по символам', function (): void {
$table = TextTable::render([['город', 'n'], ['Тула', '1'], ['Москва', '22']]);
assertSame("город | n\n-------+---\nТула | 1\nМосква | 22", $table);
});
+2 -1
View File
@@ -20,6 +20,7 @@ foreach ($cases as $case) {
removeDir(__DIR__ . '/tmp');
echo PHP_EOL . 'пройдено: ' . $passed . ', провалено: ' . $failed . PHP_EOL;
echo PHP_EOL . 'пройдено: ' . $passed . ', провалено: ' . $failed
. ($skipped > 0 ? ', пропущено: ' . $skipped : '') . PHP_EOL;
exit($failed === 0 ? 0 : 1);
+12
View File
@@ -23,6 +23,18 @@ mb_internal_encoding('UTF-8');
$passed = 0;
$failed = 0;
$skipped = 0;
/**
* Пропустить тест, которому не хватает окружения (драйвера, расширения).
*/
function skip(string $name, string $reason): void
{
global $skipped;
$skipped++;
echo 'skip ' . $name . ' — ' . $reason . PHP_EOL;
}
function test(string $name, callable $fn): void
{
+3 -1
View File
@@ -119,7 +119,9 @@ final class CsvQueryTool implements Tool
$rows = [];
while (($row = fgetcsv($handle, 0, $delimiter)) !== false) {
// enclosure и escape — явно: в PHP 8.4+ без escape предупреждение
// (значение по умолчанию поменяется). Поведение прежнее.
while (($row = fgetcsv($handle, 0, $delimiter, '"', '\\')) !== false) {
$rows[] = array_map(static fn ($cell): string => trim((string) $cell), $row);
}