From a412fff274947b14d341e59d593d8ebd9cb8d26e Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 8 Sep 2023 10:37:07 +0900 Subject: [PATCH 1/2] test: update expectation for highlight code in PHP 8.3 --- tests/system/Helpers/TextHelperTest.php | 9 ++++++++- tests/system/View/ParserFilterTest.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/system/Helpers/TextHelperTest.php b/tests/system/Helpers/TextHelperTest.php index 4d0295e11d46..60f3cc823ff7 100755 --- a/tests/system/Helpers/TextHelperTest.php +++ b/tests/system/Helpers/TextHelperTest.php @@ -263,7 +263,14 @@ public function testCensoredWordsNonReplacement(): void public function testHighlightCode(): void { - $expect = "\n<?php var_dump(\$this); ?> \n\n"; + // PHP 8.3 changes the output. + if (version_compare(PHP_VERSION, '8.3', '<')) { + $expect = "\n<?php var_dump(\$this); ?> \n\n"; + } else { + // PHP 8.3 + $expect = '
<?php var_dump($this); ?> ?>
'; + } + $this->assertSame($expect, highlight_code('')); } diff --git a/tests/system/View/ParserFilterTest.php b/tests/system/View/ParserFilterTest.php index 7b41da6060fa..a5b2b25b91dd 100644 --- a/tests/system/View/ParserFilterTest.php +++ b/tests/system/View/ParserFilterTest.php @@ -181,6 +181,22 @@ public function testHighlightCode(): void EOF; + + // PHP 8.3 changes the output. + if (version_compare(PHP_VERSION, '8.3', '<')) { + $expected = <<<'EOF' + + Sincerely  + + + EOF; + } else { + // PHP 8.3 + $expected = <<<'EOF' +
Sincerely ?>
+ EOF; + } + $this->assertSame($expected, $parser->renderString($template)); } From b46f2e0f8399f9c81271b82dfd2229591e334b8b Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 8 Sep 2023 12:12:21 +0900 Subject: [PATCH 2/2] test: use PHP_VERSION_ID instead of PHP_VERSION Easier to read. --- tests/system/Helpers/TextHelperTest.php | 7 +++---- tests/system/View/ParserFilterTest.php | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/system/Helpers/TextHelperTest.php b/tests/system/Helpers/TextHelperTest.php index 60f3cc823ff7..2af7f1387529 100755 --- a/tests/system/Helpers/TextHelperTest.php +++ b/tests/system/Helpers/TextHelperTest.php @@ -264,11 +264,10 @@ public function testCensoredWordsNonReplacement(): void public function testHighlightCode(): void { // PHP 8.3 changes the output. - if (version_compare(PHP_VERSION, '8.3', '<')) { - $expect = "\n<?php var_dump(\$this); ?> \n\n"; - } else { - // PHP 8.3 + if (PHP_VERSION_ID >= 80300) { $expect = '
<?php var_dump($this); ?> ?>
'; + } else { + $expect = "\n<?php var_dump(\$this); ?> \n\n"; } $this->assertSame($expect, highlight_code('')); diff --git a/tests/system/View/ParserFilterTest.php b/tests/system/View/ParserFilterTest.php index a5b2b25b91dd..694f3252e539 100644 --- a/tests/system/View/ParserFilterTest.php +++ b/tests/system/View/ParserFilterTest.php @@ -183,18 +183,17 @@ public function testHighlightCode(): void EOF; // PHP 8.3 changes the output. - if (version_compare(PHP_VERSION, '8.3', '<')) { + if (PHP_VERSION_ID >= 80300) { + $expected = <<<'EOF' +
Sincerely ?>
+ EOF; + } else { $expected = <<<'EOF' Sincerely  EOF; - } else { - // PHP 8.3 - $expected = <<<'EOF' -
Sincerely ?>
- EOF; } $this->assertSame($expected, $parser->renderString($template));