mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-12 19:54:12 +02:00
Merge branch 'ticket/15068' of https://github.com/javiexin/phpbb into ticket/15068
This commit is contained in:
49
tests/template/asset_test.php
Normal file
49
tests/template/asset_test.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
use phpbb\template\asset;
|
||||
|
||||
class phpbb_template_asset_test extends phpbb_test_case
|
||||
{
|
||||
public function set_path_data()
|
||||
{
|
||||
return array(
|
||||
// array(phpbb_root_path, given path, expected path),
|
||||
array('.', 'foo/bar', 'foo/bar'),
|
||||
array('../', 'foo/bar', 'foo/bar'),
|
||||
array('./phpBB/', 'foo/bar', 'foo/bar'),
|
||||
array('../', __DIR__ . '/foo/bar', '../' . basename(dirname(dirname(__DIR__))) . '/tests/template/foo/bar'),
|
||||
array('./', __DIR__ . '/foo/bar', './tests/template/foo/bar'),
|
||||
array('./phpBB/', __DIR__ . '/foo/bar', 'tests/template/foo/bar'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider set_path_data
|
||||
*/
|
||||
public function test_set_path($phpbb_root_path, $path, $expected)
|
||||
{
|
||||
$path_helper = $this->getMockBuilder('\phpbb\path_helper')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array())
|
||||
->getMock();
|
||||
|
||||
$path_helper->method('get_phpbb_root_path')
|
||||
->willReturn($phpbb_root_path);
|
||||
|
||||
$asset = new asset('', $path_helper, new phpbb\filesystem\filesystem());
|
||||
|
||||
$asset->set_path($path, true);
|
||||
$this->assertEquals($expected, $asset->get_path());
|
||||
}
|
||||
}
|
@@ -39,8 +39,9 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
$path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
|
||||
$this->assertTrue(phpbb_is_absolute($path_to_php));
|
||||
$this->assertTrue($filesystem->is_absolute_path($path_to_php));
|
||||
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
|
||||
|
||||
$cache_dir = $phpbb_root_path . 'cache/';
|
||||
|
@@ -28,13 +28,18 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
|
||||
|
||||
$defaults = $this->config_defaults();
|
||||
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
|
||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$lang = new \phpbb\language\language($lang_loader);
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
$this->user = $user;
|
||||
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
|
||||
$path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$filesystem,
|
||||
$this->getMock('\phpbb\request\request'),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
@@ -51,9 +56,29 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
|
||||
)
|
||||
);
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$cache_path = $phpbb_root_path . 'cache/twig';
|
||||
$context = new \phpbb\template\context();
|
||||
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$config,
|
||||
$filesystem,
|
||||
$path_helper,
|
||||
$cache_path,
|
||||
$this->extension_manager,
|
||||
$loader,
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
'auto_reload' => true,
|
||||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
$this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template';
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context(), $this->extension_manager);
|
||||
$this->template->set_custom_style('all', array($this->template_path, $this->ext_template_path));
|
||||
}
|
||||
}
|
||||
|
@@ -138,16 +138,39 @@ Zeta test event in all',
|
||||
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
|
||||
dirname(__FILE__) . "/datasets/$dataset/"
|
||||
);
|
||||
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
$path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
new \phpbb\filesystem\filesystem(),
|
||||
$this->getMock('\phpbb\request\request'),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager);
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$cache_path = $phpbb_root_path . 'cache/twig';
|
||||
$context = new \phpbb\template\context();
|
||||
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$config,
|
||||
$filesystem,
|
||||
$path_helper,
|
||||
$cache_path,
|
||||
$this->extension_manager,
|
||||
$loader,
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
'auto_reload' => true,
|
||||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
|
||||
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,12 @@ require_once dirname(__FILE__) . '/template_test_case_with_tree.php';
|
||||
|
||||
class phpbb_template_template_includecss_test extends phpbb_template_template_test_case_with_tree
|
||||
{
|
||||
/** @var \phpbb\path_helper */
|
||||
protected $phpbb_path_helper;
|
||||
|
||||
/** @var string */
|
||||
protected $parent_template_path;
|
||||
|
||||
protected function setup_engine(array $new_config = array())
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $user;
|
||||
@@ -22,11 +28,13 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
||||
$defaults = $this->config_defaults();
|
||||
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
|
||||
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
|
||||
$this->phpbb_path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$filesystem,
|
||||
$this->getMock('\phpbb\request\request'),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
@@ -34,11 +42,32 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
||||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
$this->parent_template_path = $this->test_path . '/parent_templates';
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$cache_path = $phpbb_root_path . 'cache/twig';
|
||||
$context = new \phpbb\template\context();
|
||||
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$config,
|
||||
$filesystem,
|
||||
$this->phpbb_path_helper,
|
||||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
'auto_reload' => true,
|
||||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new phpbb\template\twig\twig(
|
||||
$this->phpbb_path_helper,
|
||||
$config,
|
||||
$user,
|
||||
new phpbb\template\context(),
|
||||
$context,
|
||||
$twig,
|
||||
$cache_path,
|
||||
$this->user,
|
||||
array(new \phpbb\template\twig\extension($context, $this->user)),
|
||||
new phpbb_mock_extension_manager(
|
||||
dirname(__FILE__) . '/',
|
||||
array(
|
||||
@@ -50,6 +79,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
||||
)
|
||||
)
|
||||
);
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/template_test_case.php';
|
||||
|
||||
class phpbb_template_template_parser_test extends phpbb_template_template_test_case
|
||||
|
@@ -11,7 +11,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/template_test_case.php';
|
||||
|
||||
class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
@@ -129,6 +128,34 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1",
|
||||
),
|
||||
array(
|
||||
'loop_twig.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"noloop\nnoloop",
|
||||
),
|
||||
array(
|
||||
'loop_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array())),
|
||||
array(),
|
||||
"loop\nloop",
|
||||
),
|
||||
array(
|
||||
'loop_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array(), array()), 'test_loop.block' => array(array())),
|
||||
array(),
|
||||
"loop\nloop\nloop\nloop",
|
||||
),
|
||||
array(
|
||||
'loop_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array(), array()), 'test_loop.block' => array(array()), 'block' => array(array(), array())),
|
||||
array(),
|
||||
"loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1",
|
||||
),
|
||||
array(
|
||||
'loop_vars.html',
|
||||
array(),
|
||||
@@ -150,6 +177,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner",
|
||||
),
|
||||
array(
|
||||
'loop_vars_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array('VARIABLE' => 'x'))),
|
||||
array(),
|
||||
"first\n0 - a\nx - b\nset\nlast",
|
||||
),
|
||||
array(
|
||||
'loop_vars_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))),
|
||||
array(),
|
||||
"first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast",
|
||||
),
|
||||
array(
|
||||
'loop_vars_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())),
|
||||
array(),
|
||||
"first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner",
|
||||
),
|
||||
array(
|
||||
'loop_advanced.html',
|
||||
array(),
|
||||
@@ -157,6 +205,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561",
|
||||
),
|
||||
array(
|
||||
'loop_advanced_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array())),
|
||||
array(),
|
||||
"101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561",
|
||||
),
|
||||
array(
|
||||
'loop_nested2.html',
|
||||
array(),
|
||||
@@ -164,6 +219,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"o0o1m01m11",
|
||||
),
|
||||
array(
|
||||
'loop_nested2_twig.html',
|
||||
array(),
|
||||
array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())),
|
||||
array(),
|
||||
"o0o1m01m11",
|
||||
),
|
||||
array(
|
||||
'define.html',
|
||||
array(),
|
||||
@@ -243,6 +305,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array('test_loop'),
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'loop_vars_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())),
|
||||
array('test_loop'),
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'include_define_variable.html',
|
||||
array('VARIABLE' => 'variable.html'),
|
||||
@@ -274,6 +343,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"noloop\nnoloop",
|
||||
),
|
||||
array(
|
||||
// Just like a regular loop but the name begins
|
||||
// with an underscore
|
||||
'loop_underscore_twig.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"noloop\nnoloop",
|
||||
),
|
||||
array(
|
||||
'lang.html',
|
||||
array(),
|
||||
@@ -286,7 +364,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
|
||||
"Value'\n1 O'Clock\nValue\\x27\n1\\x20O\\x27Clock",
|
||||
array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"),
|
||||
),
|
||||
array(
|
||||
@@ -296,6 +374,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"top-level content",
|
||||
),
|
||||
array(
|
||||
'loop_nested_multilevel_ref_twig.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"top-level content",
|
||||
),
|
||||
array(
|
||||
'loop_nested_multilevel_ref.html',
|
||||
array(),
|
||||
@@ -303,6 +388,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz",
|
||||
),
|
||||
array(
|
||||
'loop_nested_multilevel_ref_twig.html',
|
||||
array(),
|
||||
array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
|
||||
array(),
|
||||
"top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz",
|
||||
),
|
||||
array(
|
||||
'loop_nested_deep_multilevel_ref.html',
|
||||
array(),
|
||||
@@ -310,6 +402,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
|
||||
),
|
||||
array(
|
||||
'loop_nested_deep_multilevel_ref_twig.html',
|
||||
array(),
|
||||
array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
|
||||
array(),
|
||||
"top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
|
||||
),
|
||||
array(
|
||||
'loop_size.html',
|
||||
array(),
|
||||
@@ -317,6 +416,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop",
|
||||
),
|
||||
array(
|
||||
'loop_size_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array()), 'empty_loop' => array()),
|
||||
array(),
|
||||
"nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop",
|
||||
),
|
||||
array(
|
||||
'loop_include.html',
|
||||
array(),
|
||||
@@ -324,6 +430,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
"barbarbar1bar1",
|
||||
),
|
||||
array(
|
||||
'loop_include_twig.html',
|
||||
array(),
|
||||
array('test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1'))),
|
||||
array(),
|
||||
"barbarbar1bar1",
|
||||
),
|
||||
array(
|
||||
'loop_nested_include.html',
|
||||
array(),
|
||||
@@ -335,6 +448,17 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
"[bar|[bar|]][bar1|[bar1|[bar1|works]]]",
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
'loop_nested_include_twig.html',
|
||||
array(),
|
||||
array(
|
||||
'test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1')),
|
||||
'test_loop.inner' => array(array('myinner' => 'works')),
|
||||
),
|
||||
array(),
|
||||
"[bar|[bar|]][bar1|[bar1|[bar1|works]]]",
|
||||
array(),
|
||||
),
|
||||
/* Does not pass with the current implementation.
|
||||
array(
|
||||
'loop_reuse.html',
|
||||
@@ -343,8 +467,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
// Not entirely sure what should be outputted but the current output of "a" is most certainly wrong
|
||||
"a\nb\nc\nd",
|
||||
),*/
|
||||
array(
|
||||
'loop_reuse_twig.html',
|
||||
array(),
|
||||
array('one' => array(array('VAR' => 'a'), array('VAR' => 'b')), 'one.one' => array(array('VAR' => 'c'), array('VAR' => 'd'))),
|
||||
array(),
|
||||
// Not entirely sure what should be outputted but the current output of "a" is most certainly wrong
|
||||
"a\nb\nc\nd",
|
||||
),
|
||||
*/
|
||||
array(
|
||||
'twig.html',
|
||||
array('VARIABLE' => 'FOObar',),
|
||||
@@ -359,6 +490,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
'inner_value',
|
||||
),
|
||||
array(
|
||||
'loop_expressions.html',
|
||||
array(),
|
||||
array('loop' => array(array(),array(),array(),array(),array(),array()),),
|
||||
array(),
|
||||
'yesnononoyesnoyesnonoyesnono',
|
||||
),
|
||||
array(
|
||||
'loop_expressions_twig.html',
|
||||
array(),
|
||||
array('loop' => array(array(),array(),array(),array(),array(),array()),),
|
||||
array(),
|
||||
'yesnononoyesnoyesnonoyesnono',
|
||||
),
|
||||
array(
|
||||
'loop_expressions_twig2.html',
|
||||
array('loop' => array(array(),array(),array(),array(),array(),array()),),
|
||||
array(),
|
||||
array(),
|
||||
'yesnononoyesnoyesnonoyesnono',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -559,11 +711,11 @@ EOT
|
||||
),
|
||||
array(
|
||||
'outer',
|
||||
array('VARIABLE' => 'pos #1'),
|
||||
array('VARIABLE' => 'changed'),
|
||||
0,
|
||||
'change',
|
||||
<<<EOT
|
||||
outer - 0 - pos #1
|
||||
outer - 0 - changed
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 1
|
||||
@@ -574,7 +726,124 @@ middle - 0
|
||||
middle - 1
|
||||
EOT
|
||||
,
|
||||
'Test inserting at 1 on top level block',
|
||||
'Test changing at 0 on top level block',
|
||||
),
|
||||
array(
|
||||
'outer',
|
||||
array('VARIABLE' => 'changed'),
|
||||
array('S_ROW_NUM' => 2),
|
||||
'change',
|
||||
<<<EOT
|
||||
outer - 0
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 1
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 2 - changed
|
||||
middle - 0
|
||||
middle - 1
|
||||
EOT
|
||||
,
|
||||
'Test changing at KEY on top level block',
|
||||
),
|
||||
array(
|
||||
'outer.middle',
|
||||
array('VARIABLE' => 'before'),
|
||||
false,
|
||||
'insert',
|
||||
<<<EOT
|
||||
outer - 0
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 1
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 2
|
||||
middle - 0 - before
|
||||
middle - 1
|
||||
middle - 2
|
||||
EOT
|
||||
,
|
||||
'Test inserting before on middle level block',
|
||||
),
|
||||
array(
|
||||
'outer.middle',
|
||||
array('VARIABLE' => 'after'),
|
||||
true,
|
||||
'insert',
|
||||
<<<EOT
|
||||
outer - 0
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 1
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 2
|
||||
middle - 0
|
||||
middle - 1
|
||||
middle - 2 - after
|
||||
EOT
|
||||
,
|
||||
'Test inserting after on middle level block',
|
||||
),
|
||||
array(
|
||||
'outer[1].middle',
|
||||
array('VARIABLE' => 'pos #1'),
|
||||
1,
|
||||
'insert',
|
||||
<<<EOT
|
||||
outer - 0
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 1
|
||||
middle - 0
|
||||
middle - 1 - pos #1
|
||||
middle - 2
|
||||
outer - 2
|
||||
middle - 0
|
||||
middle - 1
|
||||
EOT
|
||||
,
|
||||
'Test inserting at 1 on middle level block',
|
||||
),
|
||||
array(
|
||||
'outer[].middle',
|
||||
array('VARIABLE' => 'changed'),
|
||||
0,
|
||||
'change',
|
||||
<<<EOT
|
||||
outer - 0
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 1
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 2
|
||||
middle - 0 - changed
|
||||
middle - 1
|
||||
EOT
|
||||
,
|
||||
'Test changing at beginning of last top level block',
|
||||
),
|
||||
array(
|
||||
'outer.middle',
|
||||
array('VARIABLE' => 'changed'),
|
||||
array('S_ROW_NUM' => 1),
|
||||
'change',
|
||||
<<<EOT
|
||||
outer - 0
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 1
|
||||
middle - 0
|
||||
middle - 1
|
||||
outer - 2
|
||||
middle - 0
|
||||
middle - 1 - changed
|
||||
EOT
|
||||
,
|
||||
'Test changing at beginning of last top level block',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -632,8 +901,55 @@ EOT
|
||||
|
||||
$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');
|
||||
|
||||
$this->template->alter_block_array('outer.middle', array());
|
||||
|
||||
$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|4]middle - 1[middle|4]middle - 2[middle|4]middle - 3[middle|4]';
|
||||
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after insertion at middle level');
|
||||
|
||||
$this->template->alter_block_array('outer.middle', 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|4]middle - 1[middle|4]middle - 2 - test[middle|4]middle - 3[middle|4]';
|
||||
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification at middle level');
|
||||
}
|
||||
|
||||
public function test_find_key_index()
|
||||
{
|
||||
$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('VARIABLE' => 'zero'));
|
||||
$this->template->assign_block_vars('outer', array('VARIABLE' => 'one'));
|
||||
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '1A'));
|
||||
$this->template->assign_block_vars('outer', array('VARIABLE' => 'two'));
|
||||
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2A'));
|
||||
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2B'));
|
||||
$this->template->assign_block_vars('outer', array('VARIABLE' => 'three'));
|
||||
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3A'));
|
||||
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3B'));
|
||||
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3C'));
|
||||
|
||||
$expect = 'outer - 0 - zero[outer|4]outer - 1 - one[outer|4]middle - 0 - 1A[middle|1]outer - 2 - two[outer|4]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 3 - three[outer|4]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]';
|
||||
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification');
|
||||
|
||||
$this->template->find_key_index('outer', false);
|
||||
|
||||
$this->assertEquals(0, $this->template->find_key_index('outer', false), 'Find index at the beginning of outer loop');
|
||||
$this->assertEquals(1, $this->template->find_key_index('outer', 1), 'Find index by index in outer loop');
|
||||
$this->assertEquals(2, $this->template->find_key_index('outer', array('VARIABLE' => 'two')), 'Find index by key in outer loop');
|
||||
$this->assertEquals(3, $this->template->find_key_index('outer', true), 'Find index at the end of outer loop');
|
||||
$this->assertEquals(false, $this->template->find_key_index('outer', 7), 'Find index out of bounds of outer loop');
|
||||
|
||||
$this->assertEquals(false, $this->template->find_key_index('outer[0].middle', false), 'Find index at the beginning of middle loop, no middle block');
|
||||
$this->assertEquals(false, $this->template->find_key_index('outer[1].middle', 1), 'Find index by index in inner loop, out of bounds');
|
||||
$this->assertEquals(1, $this->template->find_key_index('outer[2].middle', array('VARIABLE' => '2B')), 'Find index by key in middle loop');
|
||||
$this->assertEquals(2, $this->template->find_key_index('outer.middle', true), 'Find index at the end of middle loop');
|
||||
|
||||
$this->assertEquals(false, $this->template->find_key_index('outer.wrong', true), 'Wrong middle block name');
|
||||
$this->assertEquals(false, $this->template->find_key_index('wrong.middle', false), 'Wrong outer block name');
|
||||
}
|
||||
public function assign_block_vars_array_data()
|
||||
{
|
||||
return array(
|
||||
|
@@ -11,10 +11,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_template_template_test_case extends phpbb_test_case
|
||||
{
|
||||
protected $lang;
|
||||
protected $template;
|
||||
protected $template_path;
|
||||
protected $user;
|
||||
@@ -24,6 +23,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
||||
// Keep the contents of the cache for debugging?
|
||||
const PRESERVE_CACHE = true;
|
||||
|
||||
static protected $language_reflection_lang;
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
$reflection = new ReflectionClass('\phpbb\language\language');
|
||||
self::$language_reflection_lang = $reflection->getProperty('lang');
|
||||
self::$language_reflection_lang->setAccessible(true);
|
||||
}
|
||||
|
||||
protected function display($handle)
|
||||
{
|
||||
ob_start();
|
||||
@@ -65,20 +75,45 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
||||
|
||||
$defaults = $this->config_defaults();
|
||||
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
|
||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$this->lang = $lang = new \phpbb\language\language($lang_loader);
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
$this->user = $user;
|
||||
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
|
||||
$path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$filesystem,
|
||||
$this->getMock('\phpbb\request\request'),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context());
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$cache_path = $phpbb_root_path . 'cache/twig';
|
||||
$context = new \phpbb\template\context();
|
||||
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$config,
|
||||
$filesystem,
|
||||
$path_helper,
|
||||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
'auto_reload' => true,
|
||||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
$this->template->set_custom_style('tests', $this->template_path);
|
||||
}
|
||||
|
||||
@@ -88,6 +123,10 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
||||
$this->setup_engine();
|
||||
|
||||
$this->template->clear_cache();
|
||||
|
||||
global $phpbb_filesystem;
|
||||
|
||||
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
@@ -121,12 +160,16 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
||||
{
|
||||
foreach ($lang_vars as $name => $value)
|
||||
{
|
||||
$this->user->lang[$name] = $value;
|
||||
self::$language_reflection_lang->setValue($this->lang, array_merge(
|
||||
self::$language_reflection_lang->getValue($this->lang),
|
||||
array($name => $value)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$expected = str_replace(array("\n", "\r", "\t"), '', $expected);
|
||||
$output = str_replace(array("\n", "\r", "\t"), '', $this->display('test'));
|
||||
|
||||
$this->assertEquals($expected, $output, "Testing $file");
|
||||
}
|
||||
}
|
||||
|
@@ -22,11 +22,13 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
||||
$defaults = $this->config_defaults();
|
||||
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
|
||||
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
|
||||
$this->phpbb_path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$filesystem,
|
||||
$this->getMock('\phpbb\request\request'),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
@@ -34,7 +36,27 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
||||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
$this->parent_template_path = $this->test_path . '/parent_templates';
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, new phpbb\template\context());
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$cache_path = $phpbb_root_path . 'cache/twig';
|
||||
$context = new \phpbb\template\context();
|
||||
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$config,
|
||||
$filesystem,
|
||||
$this->phpbb_path_helper,
|
||||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
'auto_reload' => true,
|
||||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
|
||||
}
|
||||
}
|
||||
|
19
tests/template/templates/loop_advanced_twig.html
Normal file
19
tests/template/templates/loop_advanced_twig.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{% for test_loop_inner in test_loop %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(0) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(0,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(1,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(0,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(2,4) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(0,-7) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(-2,6) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
||||
x
|
||||
{% for test_loop_inner in test_loop|subset(-2,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
|
@@ -1,11 +1,11 @@
|
||||
<!-- BEGIN loop -->
|
||||
|
||||
<!-- IF loop.S_ROW_NUM is even by 4 -->on<!-- ELSE -->off<!-- ENDIF -->
|
||||
<!-- IF loop.S_ROW_NUM is divisible by(4) -->yes<!-- ELSE -->no<!-- ENDIF -->
|
||||
|
||||
<!-- END loop -->
|
||||
|
||||
<!-- BEGIN loop -->
|
||||
|
||||
<!-- IF loop.S_ROW_NUM is odd by 3 -->on<!-- ELSE -->off<!-- ENDIF -->
|
||||
<!-- IF loop.S_ROW_NUM is divisible by(3) -->yes<!-- ELSE -->no<!-- ENDIF -->
|
||||
|
||||
<!-- END loop -->
|
||||
|
11
tests/template/templates/loop_expressions_twig.html
Normal file
11
tests/template/templates/loop_expressions_twig.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% for loop_inner in loop %}
|
||||
|
||||
{% if loop_inner.S_ROW_NUM is divisible by(4) %}yes{% else %}no{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% for loop_inner in loop %}
|
||||
|
||||
{% if loop_inner.S_ROW_NUM is divisible by(3) %}yes{% else %}no{% endif %}
|
||||
|
||||
{% endfor %}
|
11
tests/template/templates/loop_expressions_twig2.html
Normal file
11
tests/template/templates/loop_expressions_twig2.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% for loop_inner in loop %}
|
||||
|
||||
{% if loop.index0 is divisible by(4) %}yes{% else %}no{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% for loop_inner in loop %}
|
||||
|
||||
{% if loop.index0 is divisible by(3) %}yes{% else %}no{% endif %}
|
||||
|
||||
{% endfor %}
|
1
tests/template/templates/loop_include1_twig.html
Normal file
1
tests/template/templates/loop_include1_twig.html
Normal file
@@ -0,0 +1 @@
|
||||
{{ test_loop_inner.foo }}
|
4
tests/template/templates/loop_include_twig.html
Normal file
4
tests/template/templates/loop_include_twig.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{% for test_loop_inner in test_loop %}
|
||||
{{ test_loop_inner.foo }}
|
||||
{% INCLUDE 'loop_include1_twig.html' %}
|
||||
{% endfor %}
|
6
tests/template/templates/loop_nested2_twig.html
Normal file
6
tests/template/templates/loop_nested2_twig.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% for outer_inner in outer %}
|
||||
o{{ outer_inner.S_ROW_COUNT }}
|
||||
{% for middle in outer_inner.middle %}
|
||||
m{{ middle.S_ROW_COUNT }}{{ outer_inner.S_ROW_COUNT }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
@@ -0,0 +1,13 @@
|
||||
top-level content
|
||||
{% for outer_inner in outer %}
|
||||
outer
|
||||
{% for middle in outer_inner.middle %}
|
||||
{{ middle.S_BLOCK_NAME }}
|
||||
{% for inner in middle.inner %}
|
||||
inner {{ inner.VARIABLE }}
|
||||
{% if inner.S_FIRST_ROW %}
|
||||
first row of {{ inner.S_NUM_ROWS }} in {{ inner.S_BLOCK_NAME }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
5
tests/template/templates/loop_nested_include1_twig.html
Normal file
5
tests/template/templates/loop_nested_include1_twig.html
Normal file
@@ -0,0 +1,5 @@
|
||||
[{{ test_loop_inner.foo }}|
|
||||
{% for inner in test_loop_inner.inner %}
|
||||
[{{ test_loop_inner.foo }}|
|
||||
{{ inner.myinner }}]
|
||||
{% endfor %}]
|
4
tests/template/templates/loop_nested_include_twig.html
Normal file
4
tests/template/templates/loop_nested_include_twig.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{% for test_loop_inner in test_loop %}
|
||||
[{{ test_loop_inner.foo }}
|
||||
|{% INCLUDE 'loop_nested_include1_twig.html' %}]
|
||||
{% endfor %}
|
@@ -0,0 +1,10 @@
|
||||
top-level content
|
||||
{% for outer_inner in outer %}
|
||||
outer {{ outer_inner.VARIABLE }}
|
||||
{% for inner in outer_inner.inner %}
|
||||
inner {{ inner.VARIABLE }}
|
||||
{% if inner.S_FIRST_ROW %}
|
||||
first row
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
6
tests/template/templates/loop_nested_twig.html
Normal file
6
tests/template/templates/loop_nested_twig.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% for outer_inner in outer %}
|
||||
outer - {{ outer_inner.S_ROW_COUNT }}{% if outer_inner.VARIABLE %} - {{ outer_inner.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ outer_inner.S_BLOCK_NAME }}|{{ outer_inner.S_NUM_ROWS }}]{% endif %}
|
||||
{% for middle in outer_inner.middle %}
|
||||
middle - {{ middle.S_ROW_COUNT }}{% if middle.VARIABLE %} - {{ middle.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ middle.S_BLOCK_NAME }}|{{ middle.S_NUM_ROWS }}]{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
6
tests/template/templates/loop_reuse_twig.html
Normal file
6
tests/template/templates/loop_reuse_twig.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% for one_inner in one %}
|
||||
{{ one_inner.VAR }}
|
||||
{% for one_one_inner in one_inner.one %}
|
||||
{{ one_one_inner.VAR }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
39
tests/template/templates/loop_size_twig.html
Normal file
39
tests/template/templates/loop_size_twig.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{% if nonexistent_loop|length %}
|
||||
nonexistent
|
||||
{% endif %}
|
||||
|
||||
{% if nonexistent_loop|length == 0 %}
|
||||
nonexistent = 0
|
||||
{% endif %}
|
||||
|
||||
{% if ! nonexistent_loop|length %}
|
||||
! nonexistent
|
||||
{% endif %}
|
||||
|
||||
{% if empty_loop|length %}
|
||||
empty
|
||||
{% endif %}
|
||||
|
||||
{% if empty_loop|length == 0 %}
|
||||
empty = 0
|
||||
{% endif %}
|
||||
|
||||
{% if ! empty_loop|length %}
|
||||
! empty
|
||||
{% endif %}
|
||||
|
||||
{% if test_loop|length %}
|
||||
loop
|
||||
{% endif %}
|
||||
|
||||
{% if test_loop|length == 0 %}
|
||||
loop = 0
|
||||
{% endif %}
|
||||
|
||||
{% if ! test_loop|length %}
|
||||
! loop
|
||||
{% endif %}
|
||||
|
||||
{% for test_loop_inner in test_loop %}
|
||||
in loop
|
||||
{% endfor %}
|
21
tests/template/templates/loop_twig.html
Normal file
21
tests/template/templates/loop_twig.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{% for test_loop_inner in test_loop %}
|
||||
loop
|
||||
{% else %}
|
||||
noloop
|
||||
{% endfor %}
|
||||
|
||||
{% if test_loop|length %}
|
||||
loop
|
||||
{% else %}
|
||||
noloop
|
||||
{% endif %}
|
||||
|
||||
{% if test_loop|length == 2 %}
|
||||
loop
|
||||
{% endif %}
|
||||
|
||||
{% for test_loop_inner in test_loop %}
|
||||
{% for block_inner in block %}
|
||||
loop#{{ test_loop_inner.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
21
tests/template/templates/loop_underscore_twig.html
Normal file
21
tests/template/templates/loop_underscore_twig.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{% for _underscore_loop_inner in _underscore_loop %}
|
||||
loop
|
||||
{% else %}
|
||||
noloop
|
||||
{% endfor %}
|
||||
|
||||
{% if _underscore_loop|length %}
|
||||
loop
|
||||
{% else %}
|
||||
noloop
|
||||
{% endif %}
|
||||
|
||||
{% if _underscore_loop|length == 2 %}
|
||||
loop
|
||||
{% endif %}
|
||||
|
||||
{% for _underscore_loop_inner in _underscore_loop %}
|
||||
{% for block_inner in block %}
|
||||
loop#{{ loop.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
13
tests/template/templates/loop_vars_twig.html
Normal file
13
tests/template/templates/loop_vars_twig.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% for test_loop_inner in test_loop %}
|
||||
{% if test_loop_inner.S_FIRST_ROW %}first{% endif %}
|
||||
{{ test_loop_inner.S_ROW_NUM }} - a
|
||||
{{ test_loop_inner.VARIABLE }} - b
|
||||
{% if test_loop_inner.VARIABLE %}set{% endif %}
|
||||
{% if test_loop_inner.S_LAST_ROW %}
|
||||
last
|
||||
{% endif %}
|
||||
{% for inner_inner in test_loop_inner.inner %}
|
||||
{{ inner_inner.S_ROW_NUM }} - c
|
||||
{% if inner_inner.S_LAST_ROW and inner_inner.S_ROW_COUNT and inner_inner.S_NUM_ROWS %}last inner{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
Reference in New Issue
Block a user