Skip to content

Commit b46f2e0

Browse files
committed
test: use PHP_VERSION_ID instead of PHP_VERSION
Easier to read.
1 parent a412fff commit b46f2e0

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

tests/system/Helpers/TextHelperTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,10 @@ public function testCensoredWordsNonReplacement(): void
264264
public function testHighlightCode(): void
265265
{
266266
// 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
267+
if (PHP_VERSION_ID >= 80300) {
271268
$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>";
272271
}
273272

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

tests/system/View/ParserFilterTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,17 @@ public function testHighlightCode(): void
183183
EOF;
184184

185185
// PHP 8.3 changes the output.
186-
if (version_compare(PHP_VERSION, '8.3', '<')) {
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 {
187191
$expected = <<<'EOF'
188192
<code><span style="color: #000000">
189193
<span style="color: #0000BB">Sincerely&nbsp;</span>
190194
</span>
191195
</code>
192196
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;
198197
}
199198

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

0 commit comments

Comments
 (0)