aboutsummaryrefslogtreecommitdiffstats
path: root/tests/template
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2013-07-11 12:11:41 -0700
committerNils Adermann <naderman@naderman.de>2013-07-11 12:11:41 -0700
commit59f34bef087259722e1f7eaa95b96460e007cb30 (patch)
treed7dfcc712537e672a965d924cac679670d09583e /tests/template
parent7104aeb77e2f6066cbbda0585fc8523426e4b7c7 (diff)
parent947b907efef43704c620507db17aff4fe115f219 (diff)
downloadforums-59f34bef087259722e1f7eaa95b96460e007cb30.tar
forums-59f34bef087259722e1f7eaa95b96460e007cb30.tar.gz
forums-59f34bef087259722e1f7eaa95b96460e007cb30.tar.bz2
forums-59f34bef087259722e1f7eaa95b96460e007cb30.tar.xz
forums-59f34bef087259722e1f7eaa95b96460e007cb30.zip
Merge pull request #1470 from EXreaction/feature/twig
Feature/twig
Diffstat (limited to 'tests/template')
-rw-r--r--tests/template/includephp_test.php17
-rw-r--r--tests/template/invalid_constructs_test.php87
-rw-r--r--tests/template/renderer_eval_test.php31
-rw-r--r--tests/template/subdir/includephp_from_subdir_test.php4
-rw-r--r--tests/template/template_compile_test.php31
-rw-r--r--tests/template/template_events_test.php20
-rw-r--r--tests/template/template_includejs_test.php98
-rw-r--r--tests/template/template_inheritance_test.php11
-rw-r--r--tests/template/template_locate_test.php68
-rw-r--r--tests/template/template_spacing_test.php87
-rw-r--r--tests/template/template_test.php167
-rw-r--r--tests/template/template_test_case.php66
-rw-r--r--tests/template/template_test_case_with_tree.php2
-rw-r--r--tests/template/templates/define_unclosed.html2
-rw-r--r--tests/template/templates/if.html8
-rw-r--r--tests/template/templates/includejs.html46
-rw-r--r--tests/template/templates/invalid/include_nonexistent_file.html1
-rw-r--r--tests/template/templates/invalid/unknown_tag.html1
-rw-r--r--tests/template/templates/loop_nested.html8
-rw-r--r--tests/template/templates/loop_nested2.html6
-rw-r--r--tests/template/templates/loop_size.html2
-rw-r--r--tests/template/templates/loop_underscore.html2
-rw-r--r--tests/template/templates/loop_vars.html1
-rw-r--r--tests/template/templates/twig.html6
-rw-r--r--tests/template/templates/twig_parent.html7
25 files changed, 282 insertions, 497 deletions
diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php
index f1012b6939..a3dc9bd5c5 100644
--- a/tests/template/includephp_test.php
+++ b/tests/template/includephp_test.php
@@ -15,9 +15,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
{
$this->setup_engine(array('tpl_allow_php' => true));
- $cache_file = $this->template->cachepath . 'includephp_relative.html.php';
-
- $this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php", $cache_file);
+ $this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
@@ -27,9 +25,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
{
$this->setup_engine(array('tpl_allow_php' => true));
- $cache_file = $this->template->cachepath . 'includephp_variables.html.php';
-
- $this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php", $cache_file);
+ $this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_variables.html'));
$this->assertEquals("Path includes variables.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
@@ -37,11 +33,13 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
public function test_includephp_absolute()
{
- $path_to_php = dirname(__FILE__) . '/templates/_dummy_include.php.inc';
+ global $phpbb_root_path;
+
+ $path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
$this->assertTrue(phpbb_is_absolute($path_to_php));
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
- $cache_dir = dirname($this->template->cachepath) . '/';
+ $cache_dir = dirname($phpbb_root_path . 'cache') . '/';
$fp = fopen($cache_dir . 'includephp_absolute.html', 'w');
fputs($fp, $template_text);
fclose($fp);
@@ -49,9 +47,8 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
$this->setup_engine(array('tpl_allow_php' => true));
$this->style->set_custom_style('tests', $cache_dir, array(), '');
- $cache_file = $this->template->cachepath . 'includephp_absolute.html.php';
- $this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php", $cache_file);
+ $this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_absolute.html'));
$this->assertEquals("Path is absolute.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
diff --git a/tests/template/invalid_constructs_test.php b/tests/template/invalid_constructs_test.php
deleted file mode 100644
index 19d192b8b6..0000000000
--- a/tests/template/invalid_constructs_test.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2012 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-require_once dirname(__FILE__) . '/template_test_case.php';
-
-class phpbb_template_invalid_constructs_test extends phpbb_template_template_test_case
-{
- public function template_data()
- {
- return array(
- array(
- 'Unknown tag',
- 'invalid/unknown_tag.html',
- array(),
- array(),
- array(),
- 'invalid/output/unknown_tag.html',
- ),
- /*
- * Produces a parse error which is fatal, therefore
- * destroying the test suite.
- array(
- 'ENDIF without IF',
- 'invalid/endif_without_if.html',
- array(),
- array(),
- array(),
- 'invalid/output/endif_without_if.html',
- ),
- */
- );
- }
-
- public function template_data_error()
- {
- return array(
- array(
- 'Include a nonexistent file',
- 'invalid/include_nonexistent_file.html',
- array(),
- array(),
- array(),
- E_USER_ERROR,
- 'invalid/output/include_nonexistent_file.html',
- ),
- );
- }
-
- /**
- * @dataProvider template_data
- */
- public function test_template($description, $file, $vars, $block_vars, $destroy, $expected)
- {
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
-
- $this->assertFileNotExists($cache_file);
-
- $expected = file_get_contents(dirname(__FILE__) . '/templates/' . $expected);
- // apparently the template engine does not put
- // the trailing newline into compiled templates
- $expected = trim($expected);
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
- }
-
- /**
- * @dataProvider template_data_error
- */
- public function test_template_error($description, $file, $vars, $block_vars, $destroy, $error, $expected)
- {
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
-
- $this->assertFileNotExists($cache_file);
-
- $expected = file_get_contents(dirname(__FILE__) . '/templates/' . $expected);
- // apparently the template engine does not put
- // the trailing newline into compiled templates
- $expected = trim($expected);
- $this->setExpectedTriggerError($error, $expected);
- $this->run_template($file, $vars, $block_vars, $destroy, '', $cache_file);
- }
-}
diff --git a/tests/template/renderer_eval_test.php b/tests/template/renderer_eval_test.php
deleted file mode 100644
index 7ebb8b9bda..0000000000
--- a/tests/template/renderer_eval_test.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-class phpbb_template_renderer_eval_test extends phpbb_test_case
-{
- public function test_eval()
- {
- $compiled_code = '<a href="<?php echo \'Test\'; ?>">';
- $valid_code = '<a href="Test">';
- $context = new phpbb_template_context();
- $template = new phpbb_template_renderer_eval($compiled_code, NULL);
- ob_start();
- try
- {
- $template->render($context, array());
- }
- catch (Exception $exception)
- {
- ob_end_clean();
- throw $exception;
- }
- $output = ob_get_clean();
- $this->assertEquals($valid_code, $output);
- }
-}
diff --git a/tests/template/subdir/includephp_from_subdir_test.php b/tests/template/subdir/includephp_from_subdir_test.php
index 517cb85a30..6f9bc1efa6 100644
--- a/tests/template/subdir/includephp_from_subdir_test.php
+++ b/tests/template/subdir/includephp_from_subdir_test.php
@@ -19,9 +19,7 @@ class phpbb_template_subdir_includephp_from_subdir_test extends phpbb_template_t
{
$this->setup_engine(array('tpl_allow_php' => true));
- $cache_file = $this->template->cachepath . 'includephp_relative.html.php';
-
- $this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php", $cache_file);
+ $this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
diff --git a/tests/template/template_compile_test.php b/tests/template/template_compile_test.php
deleted file mode 100644
index 7393fc1747..0000000000
--- a/tests/template/template_compile_test.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
-class phpbb_template_template_compile_test extends phpbb_test_case
-{
- private $template_compile;
- private $template_path;
-
- protected function setUp()
- {
- $this->template_compile = new phpbb_template_compile(false, null, $this->style_resource_locator, '');
- $this->template_path = dirname(__FILE__) . '/templates';
- }
-
- public function test_in_phpbb()
- {
- $output = $this->template_compile->compile_file($this->template_path . '/trivial.html');
- $this->assertTrue(strlen($output) > 0);
- $statements = explode(';', $output);
- $first_statement = $statements[0];
- $this->assertTrue(!!preg_match('#if.*defined.*IN_PHPBB.*exit#', $first_statement));
- }
-}
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index 0ac50c7f2b..f7bcd2dcc6 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -54,11 +54,9 @@ class phpbb_template_template_events_test extends phpbb_template_template_test_c
array(),
array(),
array(),
-'Kappa test event in all
-Omega test event in all
-Zeta test event in all
-Kappa test event in silver
-Omega test event in silver',
+'Kappa test event in silver
+Omega test event in silver
+Zeta test event in all',
),
array(
'Template event with inheritance - child',
@@ -68,10 +66,9 @@ Omega test event in silver',
array(),
array(),
array(),
-'Kappa test event in all
-Omega test event in all
-Zeta test event in all
-Kappa test event in silver_inherit',
+'Kappa test event in silver_inherit
+Omega test event in silver
+Zeta test event in all',
),
array(
'Definition in parent style',
@@ -95,8 +92,7 @@ Kappa test event in silver_inherit',
$this->setup_engine_for_events($dataset, $style_names);
// Run test
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
+ $this->run_template($file, $vars, $block_vars, $destroy, $expected);
}
protected function setup_engine_for_events($dataset, $style_names, array $new_config = array())
@@ -111,7 +107,7 @@ Kappa test event in silver_inherit',
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
dirname(__FILE__) . "/datasets/$dataset/"
);
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context, $this->extension_manager);
+ $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager);
$this->style_provider = new phpbb_style_path_provider();
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
$this->style->set_custom_style('silver', array($this->template_path), $style_names, '');
diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php
index 22b020208b..ea5c30891b 100644
--- a/tests/template/template_includejs_test.php
+++ b/tests/template/template_includejs_test.php
@@ -11,23 +11,97 @@ require_once dirname(__FILE__) . '/template_test_case_with_tree.php';
class phpbb_template_template_includejs_test extends phpbb_template_template_test_case_with_tree
{
- public function test_includejs_compilation()
+ public function template_data()
+ {
+ return array(
+ /*
+ array(
+ // vars
+ // expected
+ ),
+ */
+ array(
+ array('TEST' => 1),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 2),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=0&assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 3),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1&assets_version=0&assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 4),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1&amp;assets_version=0&assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 5),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1;assets_version=0&assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 6),
+ '<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 7),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 8),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 9),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 10),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
+ ),
+ array(
+ array('TEST' => 11),
+ '<script type="text/javascript" src="' . $this->test_path . '/templates/child_only.js?test1=1&amp;test2=2&assets_version=1#test3"></script>',
+ ),
+ array(
+ array('TEST' => 12),
+ '<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1=1&amp;test2=2&assets_version=1#test3"></script>',
+ ),
+ array(
+ array('TEST' => 13),
+ '<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1=1;test2=2&assets_version=1#test3"></script>',
+ ),
+ array(
+ array('TEST' => 14),
+ '<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1=&quot;&assets_version=1#test3"></script>',
+ ),
+ array(
+ array('TEST' => 15),
+ '<script type="text/javascript" src="http://phpbb.com/b.js?c=d#f"></script>',
+ ),
+ array(
+ array('TEST' => 16),
+ '<script type="text/javascript" src="http://phpbb.com/b.js?c=d&assets_version=1#f"></script>',
+ ),
+ array(
+ array('TEST' => 17),
+ '<script type="text/javascript" src="//phpbb.com/b.js"></script>',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider template_data
+ */
+ public function test_includejs_compilation($vars, $expected)
{
// Reset the engine state
$this->setup_engine(array('assets_version' => 1));
- // Prepare correct result
- $scripts = array(
- '<script src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
- '<script src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
- '<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>',
- '<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
- '<script src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
- '<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
- );
+ $this->template->assign_vars($vars);
// Run test
- $cache_file = $this->template->cachepath . 'includejs.html.php';
- $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts), $cache_file);
+ $this->run_template('includejs.html', array_merge(array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), $vars), array(), array(), $expected);
}
}
diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php
index febfed9ef0..cc71ff99e0 100644
--- a/tests/template/template_inheritance_test.php
+++ b/tests/template/template_inheritance_test.php
@@ -50,15 +50,6 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t
*/
public function test_template($name, $file, array $vars, array $block_vars, array $destroy, $expected)
{
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
-
- $this->assertFileNotExists($cache_file);
-
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
-
- // Reset the engine state
- $this->setup_engine();
-
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
+ $this->run_template($file, $vars, $block_vars, $destroy, $expected);
}
}
diff --git a/tests/template/template_locate_test.php b/tests/template/template_locate_test.php
deleted file mode 100644
index 851dcae8ea..0000000000
--- a/tests/template/template_locate_test.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-require_once dirname(__FILE__) . '/template_test_case_with_tree.php';
-
-class phpbb_template_template_locate_test extends phpbb_template_template_test_case_with_tree
-{
- public function template_data()
- {
- return array(
- // First element of the array is test name - keep them distinct
- array(
- 'simple inheritance - only parent template exists',
- $this->test_path . '/parent_templates/parent_only.html',
- 'parent_only.html',
- false,
- true,
- ),
- array(
- 'simple inheritance - only child template exists',
- $this->test_path . '/templates/child_only.html',
- 'child_only.html',
- false,
- true,
- ),
- array(
- 'simple inheritance - both parent and child templates exist',
- $this->test_path . '/templates/parent_and_child.html',
- 'parent_and_child.html',
- false,
- true,
- ),
- array(
- 'find first template - only child template exists in main style',
- 'child_only.html',
- array('parent_only.html', 'child_only.html'),
- false,
- false,
- ),
- array(
- 'find first template - both templates exist in main style',
- 'parent_and_child.html',
- array('parent_and_child.html', 'child_only.html'),
- false,
- false,
- ),
- );
- }
-
- /**
- * @dataProvider template_data
- */
- public function test_template($name, $expected, $files, $return_default, $return_full_path)
- {
- // Reset the engine state
- $this->setup_engine();
-
- // Locate template
- $result = $this->style_resource_locator->get_first_template_location($files, $return_default, $return_full_path);
- $this->assertSame($expected, $result);
- }
-}
diff --git a/tests/template/template_spacing_test.php b/tests/template/template_spacing_test.php
deleted file mode 100644
index 83f8711b38..0000000000
--- a/tests/template/template_spacing_test.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-require_once dirname(__FILE__) . '/template_test_case.php';
-
-class phpbb_template_template_spacing_test extends phpbb_template_template_test_case
-{
- public function template_data()
- {
- return array(
- /*
- array(
- '', // Description
- '', // dataset
- array(), // style names
- '', // file
- array(), // vars
- array(), // block vars
- array(), // destroy
- '', // expected result
- ),
- */
- array(
- 'Spacing in templates',
- 'ext_trivial',
- array(),
- 'variable_spacing.html',
- array(
- 'VARIABLE' => '{}',
- ),
- array(),
- array(),
- '|{}|
-{}|{}|
-|{}
-<div class="{}">test</div>',
- ),
- );
- }
-
- /**
- * @dataProvider template_data
- */
- public function test_template($desc, $dataset, $style_names, $file, array $vars, array $block_vars, array $destroy, $expected)
- {
- // Run test
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
- }
-
- /**
- * @dataProvider template_data
- */
- public function test_event($desc, $dataset, $style_names, $file, array $vars, array $block_vars, array $destroy, $expected)
- {
- // Reset the engine state
- $this->setup_engine_for_events($dataset, $style_names);
-
- // Run test
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
- }
-
- protected function setup_engine_for_events($dataset, $style_names, array $new_config = array())
- {
- global $phpbb_root_path, $phpEx, $user;
-
- $defaults = $this->config_defaults();
- $config = new phpbb_config(array_merge($defaults, $new_config));
-
- $this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template";
- $this->style_resource_locator = new phpbb_style_resource_locator();
- $this->extension_manager = new phpbb_mock_filesystem_extension_manager(
- dirname(__FILE__) . "/datasets/$dataset/"
- );
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context, $this->extension_manager);
- $this->style_provider = new phpbb_style_path_provider();
- $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
- $this->style->set_custom_style('silver', array($this->template_path), $style_names, '');
- }
-}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index a3c0b69123..fedfeba33a 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -46,28 +46,42 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
- '03',
+ '03!false',
),
array(
'if.html',
array('S_VALUE' => true),
array(),
array(),
- '1',
+ '1!false',
),
array(
'if.html',
array('S_VALUE' => true, 'S_OTHER_VALUE' => true),
array(),
array(),
- '1',
+ '1!false',
),
array(
'if.html',
array('S_VALUE' => false, 'S_OTHER_VALUE' => true),
array(),
array(),
- '2',
+ '2!false',
+ ),
+ array(
+ 'if.html',
+ array('S_TEST' => false),
+ array(),
+ array(),
+ '03false',
+ ),
+ array(
+ 'if.html',
+ array('S_TEST' => 0),
+ array(),
+ array(),
+ '03!false',
),
array(
'loop.html',
@@ -116,7 +130,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())),
array(),
- "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner\ninner loop",
+ "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner",
),
array(
'loop_advanced.html',
@@ -126,6 +140,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561",
),
array(
+ 'loop_nested2.html',
+ array(),
+ array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())),
+ array(),
+ "o0o1m01m11",
+ ),
+ array(
'define.html',
array(),
array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
@@ -140,13 +161,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"abc\nzxc\ncde\nbcd",
),
array(
- 'define_unclosed.html',
- array(),
- array(),
- array(),
- "test",
- ),
- array(
'expressions.html',
array(),
array(),
@@ -247,21 +261,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
- "{ VARIABLE }\n{ 1_VARIABLE }\n{ VARIABLE }\n{ 1_VARIABLE }",
+ "VARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE",
),
array(
'lang.html',
- array('L_VARIABLE' => "Value'", 'L_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
- "Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
- ),
- array(
- 'lang.html',
- array('LA_VARIABLE' => "Value'", 'LA_1_VARIABLE' => "1 O'Clock"),
- array(),
array(),
- "{ VARIABLE }\n{ 1_VARIABLE }\nValue'\n1 O'Clock",
+ "Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
+ array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"),
),
array(
'loop_nested_multilevel_ref.html',
@@ -275,7 +283,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
array(),
- // I don't completely understand this output, hopefully it's correct
"top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz",
),
array(
@@ -283,7 +290,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
array(),
- // I don't completely understand this output, hopefully it's correct
"top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
),
array(
@@ -303,6 +309,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"a\nb\nc\nd",
),
*/
+ array(
+ 'twig.html',
+ array('VARIABLE' => 'FOObar',),
+ array(),
+ array(),
+ "13FOOBAR|foobar",
+ ),
);
}
@@ -313,24 +326,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$this->template->set_filenames(array('test' => $filename));
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
- $expecting = sprintf('style resource locator: File for handle test does not exist. Could not find: %s', $this->test_path . '/templates/' . $filename);
- $this->setExpectedTriggerError(E_USER_ERROR, $expecting);
+ $this->setExpectedException('Twig_Error_Loader');
$this->display('test');
}
- public function test_empty_file()
- {
- $expecting = 'style resource locator: set_filenames: Empty filename specified for test';
-
- $this->setExpectedTriggerError(E_USER_ERROR, $expecting);
- $this->template->set_filenames(array('test' => ''));
- }
public function test_invalid_handle()
{
- $expecting = 'No file specified for handle test';
- $this->setExpectedTriggerError(E_USER_ERROR, $expecting);
+ $this->setExpectedException('Twig_Error_Loader');
$this->display('test');
}
@@ -338,49 +342,23 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
/**
* @dataProvider template_data
*/
- public function test_template($file, array $vars, array $block_vars, array $destroy, $expected)
+ public function test_template($file, array $vars, array $block_vars, array $destroy, $expected, $lang_vars = array())
{
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
-
- $this->assertFileNotExists($cache_file);
-
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
-
- // Reset the engine state
- $this->setup_engine();
-
- $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
+ $this->run_template($file, $vars, $block_vars, $destroy, $expected, $lang_vars);
}
- /**
- * @dataProvider template_data
- */
- public function test_assign_display($file, array $vars, array $block_vars, array $destroy, $expected)
+ public function test_assign_display()
{
+ $this->run_template('basic.html', array(), array(), array(), "pass\npass\npass\n<!-- DUMMY var -->");
+
$this->template->set_filenames(array(
- 'test' => $file,
- 'container' => 'variable.html',
+ 'test' => 'basic.html',
+ 'container' => 'variable.html',
));
- $this->template->assign_vars($vars);
-
- foreach ($block_vars as $block => $loops)
- {
- foreach ($loops as $_vars)
- {
- $this->template->assign_block_vars($block, $_vars);
- }
- }
-
- foreach ($destroy as $block)
- {
- $this->template->destroy_block_vars($block);
- }
-
- $this->assertEquals($expected, self::trim_template_result($this->template->assign_display('test')), "Testing assign_display($file)");
$this->template->assign_display('test', 'VARIABLE', false);
- $this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)");
+ $this->assertEquals("pass\npass\npass\n<!-- DUMMY var -->", $this->display('container'), "Testing assign_display($file)");
}
public function test_append_var_without_assign_var()
@@ -391,7 +369,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$items = array('This ', 'is ', 'a ', 'test');
$expecting = implode('', $items);
-
+
foreach ($items as $word)
{
$this->template->append_var('VARIABLE', $word);
@@ -409,7 +387,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$start = 'This ';
$items = array('is ', 'a ', 'test');
$expecting = $start . implode('', $items);
-
+
$this->template->assign_var('VARIABLE', $start);
foreach ($items as $word)
{
@@ -421,13 +399,20 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
public function test_php()
{
- $this->setup_engine(array('tpl_allow_php' => true));
+ global $phpbb_root_path;
- $cache_file = $this->template->cachepath . 'php.html.php';
+ $template_text = '<!-- PHP -->echo "test";<!-- ENDPHP -->';
- $this->assertFileNotExists($cache_file);
+ $cache_dir = dirname($phpbb_root_path . 'cache') . '/';
+ $fp = fopen($cache_dir . 'php.html', 'w');
+ fputs($fp, $template_text);
+ fclose($fp);
- $this->run_template('php.html', array(), array(), array(), 'test', $cache_file);
+ $this->setup_engine(array('tpl_allow_php' => true));
+
+ $this->style->set_custom_style('tests', $cache_dir, array(), '');
+
+ $this->run_template('php.html', array(), array(), array(), 'test');
}
public function alter_block_array_data()
@@ -533,10 +518,40 @@ EOT
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
- $this->assertEquals("outer - 0\nmiddle - 0\nmiddle - 1\nouter - 1\nmiddle - 0\nmiddle - 1\nouter - 2\nmiddle - 0\nmiddle - 1", $this->display('test'), 'Ensuring template is built correctly before modification');
+ $this->assertEquals("outer - 0middle - 0middle - 1outer - 1middle - 0middle - 1outer - 2middle - 0middle - 1", $this->display('test'), 'Ensuring template is built correctly before modification');
$this->template->alter_block_array($alter_block, $vararray, $key, $mode);
- $this->assertEquals($expect, $this->display('test'), $description);
+ $this->assertEquals(str_replace(array("\n", "\r", "\t"), '', $expect), str_replace(array("\n", "\r", "\t"), '', $this->display('test')), $description);
}
+ public function test_more_alter_block_array()
+ {
+ $this->template->set_filenames(array('test' => 'loop_nested.html'));
+
+ $this->template->assign_var('TEST_MORE', true);
+
+ // @todo Change this
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+
+ $expect = 'outer - 0[outer|3]middle - 0[middle|1]outer - 1[outer|3]middle - 0[middle|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification');
+
+ $this->template->alter_block_array('outer', array());
+
+ $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after insertion');
+
+ $this->template->alter_block_array('outer', array('VARIABLE' => 'test'), 2, 'change');
+
+ $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
+ $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
+ }
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 5d38ebed67..3e2cd5a387 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -16,6 +16,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected $template_path;
protected $style_resource_locator;
protected $style_provider;
+ protected $user;
protected $test_path = 'tests/template';
@@ -28,7 +29,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
try
{
- $this->assertTrue($this->template->display($handle, false));
+ $this->template->display($handle, false);
}
catch (Exception $exception)
{
@@ -59,16 +60,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected function setup_engine(array $new_config = array())
{
- global $phpbb_root_path, $phpEx, $user;
+ global $phpbb_root_path, $phpEx;
$defaults = $this->config_defaults();
$config = new phpbb_config(array_merge($defaults, $new_config));
+ $this->user = new phpbb_user;
$this->template_path = $this->test_path . '/templates';
$this->style_resource_locator = new phpbb_style_resource_locator();
$this->style_provider = new phpbb_style_path_provider();
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
- $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
+ $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context());
+ $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, $this->style_provider, $this->template);
$this->style->set_custom_style('tests', $this->template_path, array(), '');
}
@@ -77,43 +79,15 @@ class phpbb_template_template_test_case extends phpbb_test_case
// Test the engine can be used
$this->setup_engine();
- $template_cache_dir = dirname($this->template->cachepath);
- if (!is_writable($template_cache_dir))
- {
- $this->markTestSkipped("Template cache directory ({$template_cache_dir}) is not writable.");
- }
-
- $file_array = scandir($template_cache_dir);
- $file_prefix = basename($this->template->cachepath);
- foreach ($file_array as $file)
- {
- if (strpos($file, $file_prefix) === 0)
- {
- unlink($template_cache_dir . '/' . $file);
- }
- }
-
- $this->setup_engine();
+ $this->template->clear_cache();
}
protected function tearDown()
{
- if (is_object($this->template))
- {
- $template_cache_dir = dirname($this->template->cachepath);
- $file_array = scandir($template_cache_dir);
- $file_prefix = basename($this->template->cachepath);
- foreach ($file_array as $file)
- {
- if (strpos($file, $file_prefix) === 0)
- {
- unlink($template_cache_dir . '/' . $file);
- }
- }
- }
+ $this->template->clear_cache();
}
- protected function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $cache_file)
+ protected function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $lang_vars = array())
{
$this->template->set_filenames(array('test' => $file));
$this->template->assign_vars($vars);
@@ -131,25 +105,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
$this->template->destroy_block_vars($block);
}
- try
+ // Previous functionality was $cachefile (string), which was removed, check to prevent errors
+ if (is_array($lang_vars))
{
- $this->assertEquals($expected, $this->display('test'), "Testing $file");
- $this->assertFileExists($cache_file);
- }
- catch (ErrorException $e)
- {
- if (file_exists($cache_file))
+ foreach ($lang_vars as $name => $value)
{
- copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file));
+ $this->user->lang[$name] = $value;
}
- throw $e;
}
- // For debugging.
- // When testing eval path the cache file may not exist.
- if (self::PRESERVE_CACHE && file_exists($cache_file))
- {
- copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file));
- }
+ $expected = str_replace(array("\n", "\r", "\t"), '', $expected);
+ $output = str_replace(array("\n", "\r", "\t"), '', $this->display('test'));
+ $this->assertEquals($expected, $output, "Testing $file");
}
}
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index 7585be5728..4b8cbada45 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -22,7 +22,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$this->parent_template_path = $this->test_path . '/parent_templates';
$this->style_resource_locator = new phpbb_style_resource_locator();
$this->style_provider = new phpbb_style_path_provider();
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
+ $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
$this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), '');
}
diff --git a/tests/template/templates/define_unclosed.html b/tests/template/templates/define_unclosed.html
deleted file mode 100644
index 1c975eab2b..0000000000
--- a/tests/template/templates/define_unclosed.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<!-- DEFINE $VALUE -->
-test
diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html
index eed431019e..c010aff7fa 100644
--- a/tests/template/templates/if.html
+++ b/tests/template/templates/if.html
@@ -9,3 +9,11 @@
<!-- IF S_VALUE and S_OTHER_VALUE and (S_VALUE > S_OTHER_VALUE) -->
04
<!-- ENDIF -->
+
+<!-- IF S_TEST === false -->
+false
+<!-- ENDIF -->
+
+<!-- IF S_TEST !== false -->
+!false
+<!-- ENDIF -->
diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html
index ef73700eeb..3bcad76af5 100644
--- a/tests/template/templates/includejs.html
+++ b/tests/template/templates/includejs.html
@@ -1,8 +1,38 @@
-<!-- INCLUDEJS parent_and_child.js -->
-<!-- INCLUDEJS {PARENT} -->
-<!-- DEFINE $TEST = 'child_only.js' -->
-<!-- INCLUDEJS {$TEST} -->
-<!-- INCLUDEJS subdir/{PARENT} -->
-<!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} -->
-<!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} -->
-{SCRIPTS}
+<!-- IF TEST === 1 -->
+ <!-- INCLUDEJS parent_and_child.js -->
+<!-- ELSEIF TEST === 2 -->
+ <!-- INCLUDEJS parent_and_child.js?assets_version=0 -->
+<!-- ELSEIF TEST === 3 -->
+ <!-- INCLUDEJS parent_and_child.js?test=1&assets_version=0 -->
+<!-- ELSEIF TEST === 4 -->
+ <!-- INCLUDEJS parent_and_child.js?test=1&amp;assets_version=0 -->
+<!-- ELSEIF TEST === 5 -->
+ <!-- INCLUDEJS parent_and_child.js?test=1;assets_version=0 -->
+<!-- ELSEIF TEST === 6 -->
+ <!-- INCLUDEJS {PARENT} -->
+<!-- ELSEIF TEST === 7 -->
+ <!-- DEFINE $TEST = 'child_only.js' -->
+ <!-- INCLUDEJS {$TEST} -->
+<!-- ELSEIF TEST === 8 -->
+ <!-- INCLUDEJS subdir/{PARENT} -->
+<!-- ELSEIF TEST === 9 -->
+ <!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} -->
+<!-- ELSEIF TEST === 10 -->
+ <!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} -->
+<!-- ELSEIF TEST === 11 -->
+ <!-- DEFINE $TEST = 'child_only.js?test1=1&amp;test2=2#test3' -->
+ <!-- INCLUDEJS {$TEST} -->
+<!-- ELSEIF TEST === 12 -->
+ <!-- INCLUDEJS parent_only.js?test1=1&amp;test2=2#test3 -->
+<!-- ELSEIF TEST === 13 -->
+ <!-- INCLUDEJS parent_only.js?test1=1;test2=2#test3 -->
+<!-- ELSEIF TEST === 14 -->
+ <!-- INCLUDEJS parent_only.js?test1=&quot;#test3 -->
+<!-- ELSEIF TEST === 15 -->
+ <!-- INCLUDEJS http://phpbb.com/b.js?c=d#f -->
+<!-- ELSEIF TEST === 16 -->
+ <!-- INCLUDEJS http://phpbb.com/b.js?c=d&assets_version=1#f -->
+<!-- ELSEIF TEST === 17 -->
+ <!-- INCLUDEJS //phpbb.com/b.js -->
+<!-- ENDIF -->
+{$SCRIPTS}
diff --git a/tests/template/templates/invalid/include_nonexistent_file.html b/tests/template/templates/invalid/include_nonexistent_file.html
deleted file mode 100644
index 617d2fdaaa..0000000000
--- a/tests/template/templates/invalid/include_nonexistent_file.html
+++ /dev/null
@@ -1 +0,0 @@
-<!-- INCLUDE nonexistent.html -->
diff --git a/tests/template/templates/invalid/unknown_tag.html b/tests/template/templates/invalid/unknown_tag.html
deleted file mode 100644
index 1489e5e31a..0000000000
--- a/tests/template/templates/invalid/unknown_tag.html
+++ /dev/null
@@ -1 +0,0 @@
-<!-- UNKNOWNTAG variable.html -->
diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html
index 45b1ef85d4..cf099ecc15 100644
--- a/tests/template/templates/loop_nested.html
+++ b/tests/template/templates/loop_nested.html
@@ -1,6 +1,6 @@
<!-- BEGIN outer -->
- outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
- <!-- BEGIN middle -->
- middle - {middle.S_ROW_COUNT}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
- <!-- END middle -->
+outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF --><!-- IF TEST_MORE -->[{outer.S_BLOCK_NAME}|{outer.S_NUM_ROWS}]<!-- ENDIF -->
+<!-- BEGIN middle -->
+middle - {outer.middle.S_ROW_COUNT}<!-- IF outer.middle.VARIABLE --> - {outer.middle.VARIABLE}<!-- ENDIF --><!-- IF TEST_MORE -->[{outer.middle.S_BLOCK_NAME}|{outer.middle.S_NUM_ROWS}]<!-- ENDIF -->
+<!-- END middle -->
<!-- END outer -->
diff --git a/tests/template/templates/loop_nested2.html b/tests/template/templates/loop_nested2.html
new file mode 100644
index 0000000000..3eeeb5e36a
--- /dev/null
+++ b/tests/template/templates/loop_nested2.html
@@ -0,0 +1,6 @@
+<!-- BEGIN outer -->
+o{outer.S_ROW_COUNT}
+<!-- BEGIN middle -->
+m{outer.middle.S_ROW_COUNT}{outer.S_ROW_COUNT}
+<!-- END middle -->
+<!-- END outer -->
diff --git a/tests/template/templates/loop_size.html b/tests/template/templates/loop_size.html
index f1938441df..8f581cef10 100644
--- a/tests/template/templates/loop_size.html
+++ b/tests/template/templates/loop_size.html
@@ -36,4 +36,4 @@
<!-- BEGIN loop -->
in loop
-<!-- END -->
+<!-- END loop -->
diff --git a/tests/template/templates/loop_underscore.html b/tests/template/templates/loop_underscore.html
index dafce5dea6..4001007868 100644
--- a/tests/template/templates/loop_underscore.html
+++ b/tests/template/templates/loop_underscore.html
@@ -2,7 +2,7 @@
loop
<!-- BEGINELSE -->
noloop
-<!-- END loop -->
+<!-- END _underscore_loop -->
<!-- IF ._underscore_loop -->
loop
diff --git a/tests/template/templates/loop_vars.html b/tests/template/templates/loop_vars.html
index d94a0ae0f7..7d86d4b7b6 100644
--- a/tests/template/templates/loop_vars.html
+++ b/tests/template/templates/loop_vars.html
@@ -11,4 +11,3 @@ last
<!-- IF inner.S_LAST_ROW and inner.S_ROW_COUNT and inner.S_NUM_ROWS -->last inner<!-- ENDIF -->
<!-- END inner -->
<!-- END loop -->
-<!-- IF .loop.inner -->inner loop<!-- ENDIF -->
diff --git a/tests/template/templates/twig.html b/tests/template/templates/twig.html
new file mode 100644
index 0000000000..17b94ad8d4
--- /dev/null
+++ b/tests/template/templates/twig.html
@@ -0,0 +1,6 @@
+<!-- EXTENDS "twig_parent.html" -->
+
+<!-- BLOCK overwritten -->
+3{VARIABLE|upper}|{VARIABLE|lower}
+<!-- ENDBLOCK -->
+
diff --git a/tests/template/templates/twig_parent.html b/tests/template/templates/twig_parent.html
new file mode 100644
index 0000000000..af528e0da4
--- /dev/null
+++ b/tests/template/templates/twig_parent.html
@@ -0,0 +1,7 @@
+<!-- BLOCK notoverwritten -->
+1
+<!-- ENDBLOCK -->
+
+<!-- BLOCK overwritten -->
+2
+<!-- ENDBLOCK --> \ No newline at end of file