|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Languages\Dockerfile; |
| 6 | + |
| 7 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | +use Tempest\Highlight\Highlighter; |
| 10 | + |
| 11 | +class DockerfileLanguageTest extends TestCase |
| 12 | +{ |
| 13 | + #[DataProvider('provide_highlight_cases')] |
| 14 | + public function test_highlight(string $content, string $expected): void |
| 15 | + { |
| 16 | + $highlighter = new Highlighter(); |
| 17 | + |
| 18 | + $this->assertSame( |
| 19 | + $expected, |
| 20 | + $highlighter->parse($content, 'dockerfile'), |
| 21 | + ); |
| 22 | + } |
| 23 | + |
| 24 | + public static function provide_highlight_cases(): iterable |
| 25 | + { |
| 26 | + return [ |
| 27 | + ['FROM python:3.13', '<span class="hl-keyword">FROM</span> <span class="hl-value">python</span>:<span class="hl-value">3.13</span>'], |
| 28 | + ['FROM php AS stage-one', '<span class="hl-keyword">FROM</span> <span class="hl-value">php</span> <span class="hl-keyword">AS</span> <span class="hl-value">stage-one</span>'], |
| 29 | + ['WORKDIR /usr/local/app', '<span class="hl-keyword">WORKDIR</span> /usr/local/app'], |
| 30 | + ['CMD ["node", "./src/index.js"]', '<span class="hl-keyword">CMD</span> [<span class="hl-value">"node"</span>, <span class="hl-value">"./src/index.js"</span>]'], |
| 31 | + ["CMD ['php', 'index.php']", '<span class="hl-keyword">CMD</span> [<span class="hl-value">\'php\'</span>, <span class="hl-value">\'index.php\'</span>]'], |
| 32 | + ['# This is a comment', '<span class="hl-comment"># This is a comment</span>'], |
| 33 | + ]; |
| 34 | + } |
| 35 | +} |
0 commit comments