Skip to content

Commit 1891963

Browse files
authored
Merge pull request #7912 from kenjis/test-highlight-code
[PHP 8.3] test: update expectation for highlight code
2 parents aa2ca35 + b46f2e0 commit 1891963

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/system/Helpers/TextHelperTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,13 @@ 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 (PHP_VERSION_ID >= 80300) {
268+
$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>';
269+
} else {
270+
$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>";
271+
}
272+
267273
$this->assertSame($expect, highlight_code('<?php var_dump($this); ?>'));
268274
}
269275

tests/system/View/ParserFilterTest.php

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

0 commit comments

Comments
 (0)