Skip to content

Commit

Permalink
Merge pull request #7912 from kenjis/test-highlight-code
Browse files Browse the repository at this point in the history
[PHP 8.3] test: update expectation for highlight code
  • Loading branch information
kenjis authored Sep 8, 2023
2 parents aa2ca35 + b46f2e0 commit 1891963
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/system/Helpers/TextHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,13 @@ 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 (PHP_VERSION_ID >= 80300) {
$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>';
} else {
$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>";
}

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

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

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

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

Expand Down

0 comments on commit 1891963

Please sign in to comment.