Skip to content

Commit

Permalink
test: update expectation for highlight code in PHP 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 8, 2023
1 parent ec8ba91 commit a412fff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/system/Helpers/TextHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,14 @@ public function testCensoredWordsNonReplacement(): void

public function testHighlightCode(): void
{
$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>";
// PHP 8.3 changes the output.
if (version_compare(PHP_VERSION, '8.3', '<')) {
$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>";
} else {
// PHP 8.3
$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>';
}

$this->assertSame($expect, highlight_code('<?php var_dump($this); ?>'));
}

Expand Down
16 changes: 16 additions & 0 deletions tests/system/View/ParserFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ public function testHighlightCode(): void
</span>
</code>
EOF;

// PHP 8.3 changes the output.
if (version_compare(PHP_VERSION, '8.3', '<')) {
$expected = <<<'EOF'
<code><span style="color: #000000">
<span style="color: #0000BB">Sincerely&nbsp;</span>
</span>
</code>
EOF;
} else {
// PHP 8.3
$expected = <<<'EOF'
<pre><code style="color: #000000"><span style="color: #0000BB">Sincerely ?&gt;</span></code></pre>
EOF;
}

$this->assertSame($expected, $parser->renderString($template));
}

Expand Down

0 comments on commit a412fff

Please sign in to comment.