diff --git a/tests/_data/template/v2example.compiled.html b/tests/_data/template/v2example.compiled.html index b8a1fb282..5d8f6cfb7 100644 --- a/tests/_data/template/v2example.compiled.html +++ b/tests/_data/template/v2example.compiled.html @@ -29,14 +29,14 @@ -_v2_initLoopVar("64b3371f38fea1", $__tmp_64b3371f38fea1); foreach ($__tmp_64b3371f38fea1 as $__Context->k => $__Context->val): ?> +_v2_initLoopVar("RANDOM_LOOP_ID", $__tmp_RANDOM_LOOP_ID); foreach ($__tmp_RANDOM_LOOP_ID as $__Context->k => $__Context->val): ?>
nosuchvar)): ?> unit tests are cool k >= 2): ?>class="config->context === 'JS' ? escape_js($__Context->val ?? '') : htmlspecialchars($__Context->val ?? '', \ENT_QUOTES, 'UTF-8', false); ?>">
-_v2_incrLoopVar($__loop_64b3371f38fea1); endforeach; $this->_v2_removeLoopVar($__loop_64b3371f38fea1); unset($__loop_64b3371f38fea1); else: ?>
Nothing here...
+_v2_incrLoopVar($__loop_RANDOM_LOOP_ID); endforeach; $this->_v2_removeLoopVar($__loop_RANDOM_LOOP_ID); unset($__loop_RANDOM_LOOP_ID); else: ?>
Nothing here...
_fragments[$__last_fragment_name] = ob_get_flush(); ?> _v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', $__Context->bar, 'var'); ?> diff --git a/tests/unit/framework/parsers/TemplateParserV2Test.php b/tests/unit/framework/parsers/TemplateParserV2Test.php index 0fc8c750f..5aecf46f9 100644 --- a/tests/unit/framework/parsers/TemplateParserV2Test.php +++ b/tests/unit/framework/parsers/TemplateParserV2Test.php @@ -1028,9 +1028,9 @@ class TemplateParserV2Test extends \Codeception\Test\Unit // Get compiled code $compiled_output = $tmpl->compileDirect('./tests/_data/template', 'v2example.html'); $tmpvar = preg_match('/\$__tmp_([0-9a-f]{14})/', $compiled_output, $m) ? $m[1] : ''; + $compiled_output = strtr($compiled_output, [$tmpvar => 'RANDOM_LOOP_ID']); //Rhymix\Framework\Storage::write(\RX_BASEDIR . 'tests/_data/template/v2example.compiled.html', $compiled_output); $expected = file_get_contents(\RX_BASEDIR . 'tests/_data/template/v2example.compiled.html'); - $expected = preg_replace('/RANDOM_LOOP_ID/', $tmpvar, $expected); $this->assertEquals( $this->_normalizeWhitespace($expected), $this->_normalizeWhitespace($compiled_output) @@ -1040,7 +1040,6 @@ class TemplateParserV2Test extends \Codeception\Test\Unit $executed_output = $tmpl->compile(); //Rhymix\Framework\Storage::write(\RX_BASEDIR . 'tests/_data/template/v2example.executed.html', $executed_output); $expected = file_get_contents(\RX_BASEDIR . 'tests/_data/template/v2example.executed.html'); - $expected = preg_replace('/RANDOM_LOOP_ID/', $tmpvar, $expected); $this->assertEquals( $this->_normalizeWhitespace($expected), $this->_normalizeWhitespace($executed_output) @@ -1050,7 +1049,6 @@ class TemplateParserV2Test extends \Codeception\Test\Unit $fragment_output = $tmpl->getFragment('rhymix'); //Rhymix\Framework\Storage::write(\RX_BASEDIR . 'tests/_data/template/v2example.fragment.html', $fragment_output); $expected = file_get_contents(\RX_BASEDIR . 'tests/_data/template/v2example.fragment.html'); - $expected = preg_replace('/RANDOM_LOOP_ID/', $tmpvar, $expected); $this->assertEquals( $this->_normalizeWhitespace($expected), $this->_normalizeWhitespace($fragment_output)