diff options
Diffstat (limited to 'tests/template/template_test.php')
-rw-r--r-- | tests/template/template_test.php | 158 |
1 files changed, 155 insertions, 3 deletions
diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 69546cc227..ca1414ec45 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -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 @@ -130,6 +129,34 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "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(), array('test_loop' => array(array('VARIABLE' => 'x'))), @@ -151,6 +178,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "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(), array('test_loop' => array(array(), array(), array(), array(), array(), array(), array())), @@ -158,6 +206,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_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(), array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())), @@ -165,6 +220,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "o0o1m01m11", ), array( + 'loop_nested2_twig.html', + array(), + array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())), + array(), + "o0o1m01m11", + ), + array( 'define.html', array(), array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), @@ -244,6 +306,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case '', ), 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'), array(), @@ -275,6 +344,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "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(), 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( @@ -297,6 +375,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "top-level content", ), array( + 'loop_nested_multilevel_ref_twig.html', + array(), + array(), + array(), + "top-level content", + ), + array( 'loop_nested_multilevel_ref.html', array(), array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))), @@ -304,6 +389,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "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(), array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))), @@ -311,6 +403,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "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(), array('test_loop' => array(array()), 'empty_loop' => array()), @@ -318,6 +417,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "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(), array('test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1'))), @@ -325,6 +431,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "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(), 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', + ), ); } |