Files
haushalt/backend/vendor/doctrine/sql-formatter/bin/regenerate-expected-output
2026-03-24 00:04:55 +01:00

30 lines
979 B
PHP
Executable File

#!/usr/bin/env php
<?php
use Doctrine\SqlFormatter\CliHighlighter;
use Doctrine\SqlFormatter\HtmlHighlighter;
use Doctrine\SqlFormatter\NullHighlighter;
use Doctrine\SqlFormatter\SqlFormatter;
use Doctrine\SqlFormatter\Tests\SqlFormatterTest;
require __DIR__ . '/../vendor/autoload.php';
$formatter = new SqlFormatter(new HtmlHighlighter());
updateExpected('format-highlight.html', [$formatter, 'format']);
updateExpected('format.txt', [new SqlFormatter(new NullHighlighter()), 'format']);
updateExpected('highlight.html', [$formatter, 'highlight']);
updateExpected('clihighlight.txt', [new SqlFormatter(new CliHighlighter()), 'format']);
updateExpected('compress.txt', [$formatter, 'compress']);
function updateExpected(string $filename, callable $highlight): void
{
$data = [];
foreach (SqlFormatterTest::fileSqlData() as $sql) {
$data[] = rtrim($highlight($sql), "\n");
}
file_put_contents(__DIR__ . '/../tests/' . $filename, implode("\n---\n", $data) . "\n");
}