Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/SqlFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
use Doctrine\SqlFormatter\SqlFormatter;
use Generator;
use PHPUnit\Framework\TestCase;
use UnexpectedValueException;

use function assert;
use function count;
use function defined;
use function explode;
use function file_get_contents;
use function pack;
use function sprintf;
use function trim;

/**
Expand Down Expand Up @@ -124,6 +127,14 @@ private function fileDataProvider(string $file): Generator
assert($contents !== false);
$formatHighlightData = explode("\n---\n", $contents);
$sqlData = $this->sqlData();
if (count($formatHighlightData) !== count($sqlData)) {
throw new UnexpectedValueException(sprintf(
'"%s" (%d sections) and sql.sql (%d sections) should have the same number of sections',
$file,
count($formatHighlightData),
count($sqlData)
));
}

foreach ($formatHighlightData as $i => $data) {
yield [$sqlData[$i], $data];
Expand Down
6 changes: 6 additions & 0 deletions tests/clihighlight.html
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,9 @@
[sqlserver]
FROM
[escap[e]]d style];
---
SELECT
a
FROM
b
LEFT OUTER JOIN c on (d = f);
6 changes: 6 additions & 0 deletions tests/format-highlight.html
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,9 @@
<span style="color: purple;">[sqlserver]</span>
<span style="font-weight:bold;">FROM</span>
<span style="color: purple;">[escap[e]]d style]</span><span >;</span></pre>
---
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span>
<span style="color: #333;">a</span>
<span style="font-weight:bold;">FROM</span>
<span style="color: #333;">b</span>
<span style="font-weight:bold;">LEFT OUTER JOIN</span> <span style="color: #333;">c</span> <span style="font-weight:bold;">on</span> (<span style="color: #333;">d</span> <span >=</span> <span style="color: #333;">f</span>)<span >;</span></pre>
6 changes: 6 additions & 0 deletions tests/format.html
Original file line number Diff line number Diff line change
Expand Up @@ -816,3 +816,9 @@
[sqlserver]
FROM
[escap[e]]d style];
---
SELECT
a
FROM
b
LEFT OUTER JOIN c on (d = f);
4 changes: 4 additions & 0 deletions tests/highlight.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,7 @@
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: blue;">&quot;no closing quote</span></pre>
---
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: purple;">[sqlserver]</span> <span style="font-weight:bold;">FROM</span> <span style="color: purple;">[escap[e]]d style]</span><span >;</span></pre>
---
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #333;">a</span> <span style="font-weight:bold;">FROM</span> <span style="color: #333;">b</span> <span style="font-weight:bold;">LEFT
OUTER
JOIN</span> <span style="color: #333;">c</span> <span style="font-weight:bold;">on</span> (<span style="color: #333;">d</span><span >=</span><span style="color: #333;">f</span>)<span >;</span></pre>