mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Fix random loop ID always changing in template v2 unit test
This commit is contained in:
parent
c487c13864
commit
c50cc71ce1
2 changed files with 3 additions and 5 deletions
|
|
@ -29,14 +29,14 @@
|
|||
</div>
|
||||
|
||||
<?php ob_start(); $__last_fragment_name = 'rhymix'; ?>
|
||||
<?php $__tmp_64b3371f38fea1 = Context::get('bar') ?? []; if($__tmp_64b3371f38fea1): $__loop_64b3371f38fea1 = $this->_v2_initLoopVar("64b3371f38fea1", $__tmp_64b3371f38fea1); foreach ($__tmp_64b3371f38fea1 as $__Context->k => $__Context->val): ?>
|
||||
<?php $__tmp_RANDOM_LOOP_ID = Context::get('bar') ?? []; if($__tmp_RANDOM_LOOP_ID): $__loop_RANDOM_LOOP_ID = $this->_v2_initLoopVar("RANDOM_LOOP_ID", $__tmp_RANDOM_LOOP_ID); foreach ($__tmp_RANDOM_LOOP_ID as $__Context->k => $__Context->val): ?>
|
||||
<div>
|
||||
<?php if (empty($__Context->nosuchvar)): ?>
|
||||
<img src="/rhymix/tests/_data/template/bar/rhymix.svg" alt="unit tests are cool" />
|
||||
<span <?php if ($__Context->k >= 2): ?>class="<?php echo $this->config->context === 'JS' ? escape_js($__Context->val ?? '') : htmlspecialchars($__Context->val ?? '', \ENT_QUOTES, 'UTF-8', false); ?>"<?php endif; ?>></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php $this->_v2_incrLoopVar($__loop_64b3371f38fea1); endforeach; $this->_v2_removeLoopVar($__loop_64b3371f38fea1); unset($__loop_64b3371f38fea1); else: ?><div>Nothing here...</div><?php endif; ?>
|
||||
<?php $this->_v2_incrLoopVar($__loop_RANDOM_LOOP_ID); endforeach; $this->_v2_removeLoopVar($__loop_RANDOM_LOOP_ID); unset($__loop_RANDOM_LOOP_ID); else: ?><div>Nothing here...</div><?php endif; ?>
|
||||
<?php $this->_fragments[$__last_fragment_name] = ob_get_flush(); ?>
|
||||
|
||||
<?php (function($__filename, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__filename = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): echo $this->_v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', $__Context->bar, 'var'); ?>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue