Skip to content

Commit a412fff

Browse files
committed
test: update expectation for highlight code in PHP 8.3
1 parent ec8ba91 commit a412fff

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

tests/system/Helpers/TextHelperTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,14 @@ public function testCensoredWordsNonReplacement(): void
263263

264264
public function testHighlightCode(): void
265265
{
266-
$expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\">&lt;?php&nbsp;var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">);&nbsp;</span><span style=\"color: #0000BB\">?&gt;&nbsp;</span>\n</span>\n</code>";
266+
// PHP 8.3 changes the output.
267+
if (version_compare(PHP_VERSION, '8.3', '<')) {
268+
$expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\">&lt;?php&nbsp;var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">);&nbsp;</span><span style=\"color: #0000BB\">?&gt;&nbsp;</span>\n</span>\n</code>";
269+
} else {
270+
// PHP 8.3
271+
$expect = '<pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">); </span><span style="color: #0000BB">?&gt; ?&gt;</span></code></pre>';
272+
}
273+
267274
$this->assertSame($expect, highlight_code('<?php var_dump($this); ?>'));
268275
}
269276

tests/system/View/ParserFilterTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,22 @@ public function testHighlightCode(): void
181181
</span>
182182
</code>
183183
EOF;
184+
185+
// PHP 8.3 changes the output.
186+
if (version_compare(PHP_VERSION, '8.3', '<')) {
187+
$expected = <<<'EOF'
188+
<code><span style="color: #000000">
189+
<span style="color: #0000BB">Sincerely&nbsp;</span>
190+
</span>
191+
</code>
192+
EOF;
193+
} else {
194+
// PHP 8.3
195+
$expected = <<<'EOF'
196+
<pre><code style="color: #000000"><span style="color: #0000BB">Sincerely ?&gt;</span></code></pre>
197+
EOF;
198+
}
199+
184200
$this->assertSame($expected, $parser->renderString($template));
185201
}
186202

0 commit comments

Comments
 (0)