Skip to content

Commit 330cc08

Browse files
committed
test(e107RequireLegacyTemplate): rewrite cache-reuse template body to PHP 5.6-safe form
testRequireReusesCacheOnSecondCall builds a PHP template source as a string, writes it to a temp file, and require()s the file three times. The original body used null-coalescing (??) to seed $GLOBALS['__test_cached'], which PHP 5.6 parses at require-time and fatals on, killing the test process with exit 255 before PHPUnit can record the failure. Every test in the file runs to completion on PHP 5.6 except this one, and the two that come after it never get a chance to execute. Rewrite the body to use isset()-ternary, which is semantically identical and parses cleanly on every PHP version in the matrix. The test itself (the outer file) was already 5.6-safe because the ?? lived inside a string literal; only the templated source needed updating.
1 parent 9ab57a7 commit 330cc08

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

e107_tests/tests/unit/e107RequireLegacyTemplateTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,10 @@ public function testRequireWithNoLanReferencesIsNoop()
216216
public function testRequireReusesCacheOnSecondCall()
217217
{
218218
// Indirect check: second call with same path should still work (and
219-
// for templates with no LAN_*, must not emit warnings).
220-
$body = "<?php\n\$GLOBALS['__test_cached'] = (\$GLOBALS['__test_cached'] ?? 0) + 1;\n";
219+
// for templates with no LAN_*, must not emit warnings). The body
220+
// uses isset()-ternary rather than ?? because PHP 5.6 has to parse
221+
// the templated source on require, and ?? is a parse error there.
222+
$body = "<?php\n\$GLOBALS['__test_cached'] = (isset(\$GLOBALS['__test_cached']) ? \$GLOBALS['__test_cached'] : 0) + 1;\n";
221223
$path = $this->writeTempTemplate('cached.php', $body);
222224

223225
e107::requireLegacyTemplate($path);

0 commit comments

Comments
 (0)