diff --git a/tests/_data/template/v2example.html b/tests/_data/template/v2example.html
index e69de29bb..49b49628b 100644
--- a/tests/_data/template/v2example.html
+++ b/tests/_data/template/v2example.html
@@ -0,0 +1,50 @@
+
The full class name is {get_class(new Push)|escape}, {Push::class} really.
+@enddesktop + + + + diff --git a/tests/_data/template/v2result1.php b/tests/_data/template/v2result1.php new file mode 100644 index 000000000..e60aabfbf --- /dev/null +++ b/tests/_data/template/v2result1.php @@ -0,0 +1,50 @@ +config->version = 2; ?> + + +setVars($__vars); echo $__tpl->compile(); })("common/tpl", 'refresh.html'); ?> + + + +foo = 'FOOFOOFOO'; +?> +bar = ['Rhy', 'miX', 'is', 'da', 'BEST!']; +?> + + {{ $foo }} + + + + +Hello foo ?? ''; ?>
+bar)), \ENT_QUOTES, 'UTF-8', false); ?>
+ +The full class name is , really.
+ + + + + diff --git a/tests/_data/template/v2result2.php b/tests/_data/template/v2result2.php new file mode 100644 index 000000000..c44af8993 --- /dev/null +++ b/tests/_data/template/v2result2.php @@ -0,0 +1,49 @@ + + + + + + {{ $foo }} + + + + + + +The full class name is Rhymix\Framework\Push, Rhymix\Framework\Push really.
+ + + + diff --git a/tests/unit/framework/parsers/TemplateParserV2Test.php b/tests/unit/framework/parsers/TemplateParserV2Test.php index c011d3860..4d1251c99 100644 --- a/tests/unit/framework/parsers/TemplateParserV2Test.php +++ b/tests/unit/framework/parsers/TemplateParserV2Test.php @@ -976,7 +976,25 @@ class TemplateParserV2Test extends \Codeception\Test\Unit public function testCompile() { + Context::init(); + $tmpl = new \Rhymix\Framework\Template('./tests/_data/template', 'v2example.html'); + $compiled_output = $tmpl->compileDirect('./tests/_data/template', 'v2example.html'); + $tmpvar = preg_match('/(\$__tmp_[0-9a-f]{14})/', $compiled_output, $m) ? $m[1] : ''; + //file_put_contents(\RX_BASEDIR . 'tests/_data/template/v2result1.php', $compiled_output); + + $expected = file_get_contents(\RX_BASEDIR . 'tests/_data/template/v2result1.php'); + $expected = preg_replace('/(\$__tmp_[0-9a-f]{14})/', $tmpvar, $expected); + $this->assertEquals($expected, $compiled_output); + + $executed_output = $tmpl->compile(); + $executed_output = preg_replace('/\n/', '', $executed_output); + $tmpvar = preg_match('/(\$__tmp_[0-9a-f]{14})/', $executed_output, $m) ? $m[1] : ''; + //file_put_contents(\RX_BASEDIR . 'tests/_data/template/v2result2.php', $executed_output); + + $expected = file_get_contents(\RX_BASEDIR . 'tests/_data/template/v2result2.php'); + $expected = preg_replace('/(\$__tmp_[0-9a-f]{14})/', $tmpvar, $expected); + $this->assertEquals($expected, $executed_output); } protected function _parse($source, $force_v2 = true)