From 8da3723a6009e14c576d53d88d3f5aeacaac238a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 28 Jun 2010 12:04:24 +0200 Subject: [PATCH] moved fixtures directory --- test/Twig/Tests/Fixtures/expressions/array.test | 49 ++++++++++++++++++++ .../Tests/Fixtures/expressions/array_call.test | 14 ++++++ test/Twig/Tests/Fixtures/expressions/binary.test | 42 +++++++++++++++++ .../Tests/Fixtures/expressions/comparison.test | 16 ++++++ test/Twig/Tests/Fixtures/expressions/dotdot.test | 17 +++++++ test/Twig/Tests/Fixtures/expressions/grouping.test | 8 +++ test/Twig/Tests/Fixtures/expressions/in.test | 15 ++++++ .../Tests/Fixtures/expressions/magic_call.test | 27 +++++++++++ .../Tests/Fixtures/expressions/method_call.test | 20 ++++++++ .../Fixtures/expressions/ternary_operator.test | 14 ++++++ test/Twig/Tests/Fixtures/expressions/unary.test | 10 ++++ test/Twig/Tests/Fixtures/filters/cycle.test | 16 ++++++ test/Twig/Tests/Fixtures/filters/date.test | 23 +++++++++ test/Twig/Tests/Fixtures/filters/default.test | 10 ++++ test/Twig/Tests/Fixtures/filters/even.test | 9 ++++ test/Twig/Tests/Fixtures/filters/format.test | 8 +++ test/Twig/Tests/Fixtures/filters/in.test | 27 +++++++++++ test/Twig/Tests/Fixtures/filters/length.test | 10 ++++ test/Twig/Tests/Fixtures/filters/odd.test | 10 ++++ test/Twig/Tests/Fixtures/filters/sort.test | 10 ++++ .../Twig/Tests/Fixtures/tags/autoescape/basic.test | 22 +++++++++ .../Tests/Fixtures/tags/autoescape/blocks.test | 12 +++++ .../Fixtures/tags/autoescape/double_escaping.test | 10 ++++ .../Tests/Fixtures/tags/autoescape/literal.test | 10 ++++ .../Tests/Fixtures/tags/autoescape/nested.test | 26 ++++++++++ .../Tests/Fixtures/tags/autoescape/objects.test | 19 ++++++++ test/Twig/Tests/Fixtures/tags/autoescape/safe.test | 10 ++++ .../Tests/Fixtures/tags/autoescape/strategy.test | 11 ++++ .../Fixtures/tags/autoescape/with_filters.test | 14 ++++++ .../tags/autoescape/with_filters_arguments.test | 20 ++++++++ test/Twig/Tests/Fixtures/tags/block/basic.test | 11 ++++ test/Twig/Tests/Fixtures/tags/filter/basic.test | 10 ++++ test/Twig/Tests/Fixtures/tags/filter/multiple.test | 10 ++++ test/Twig/Tests/Fixtures/tags/filter/nested.test | 16 ++++++ .../Tests/Fixtures/tags/filter/with_for_tag.test | 13 +++++ .../Tests/Fixtures/tags/filter/with_if_tag.test | 29 ++++++++++++ test/Twig/Tests/Fixtures/tags/for/context.test | 18 +++++++ test/Twig/Tests/Fixtures/tags/for/else.test | 21 ++++++++ .../Tests/Fixtures/tags/for/inner_variables.test | 17 +++++++ test/Twig/Tests/Fixtures/tags/for/keys.test | 11 ++++ .../Tests/Fixtures/tags/for/keys_and_values.test | 11 ++++ .../Twig/Tests/Fixtures/tags/for/loop_context.test | 19 ++++++++ .../Fixtures/tags/for/loop_context_local.test | 10 ++++ test/Twig/Tests/Fixtures/tags/for/nested_else.test | 17 +++++++ test/Twig/Tests/Fixtures/tags/for/objects.test | 43 +++++++++++++++++ .../Tests/Fixtures/tags/for/objects_countable.test | 47 +++++++++++++++++++ test/Twig/Tests/Fixtures/tags/for/recursive.test | 18 +++++++ test/Twig/Tests/Fixtures/tags/for/values.test | 11 ++++ test/Twig/Tests/Fixtures/tags/if/basic.test | 22 +++++++++ test/Twig/Tests/Fixtures/tags/if/expression.test | 22 +++++++++ test/Twig/Tests/Fixtures/tags/include/basic.test | 16 ++++++ .../Tests/Fixtures/tags/include/expression.test | 16 ++++++ .../Fixtures/tags/include/template_instance.test | 10 ++++ .../Fixtures/tags/include/with_variables.test | 12 +++++ .../Tests/Fixtures/tags/inheritance/basic.test | 14 ++++++ .../Fixtures/tags/inheritance/conditional.test | 14 ++++++ .../Tests/Fixtures/tags/inheritance/dynamic.test | 14 ++++++ .../Tests/Fixtures/tags/inheritance/multiple.test | 12 +++++ .../Tests/Fixtures/tags/inheritance/parent.test | 12 +++++ .../Fixtures/tags/inheritance/parent_nested.test | 27 +++++++++++ .../tags/inheritance/template_instance.test | 14 ++++++ test/Twig/Tests/Fixtures/tags/macro/basic.test | 15 ++++++ test/Twig/Tests/Fixtures/tags/macro/external.test | 17 +++++++ .../Tests/Fixtures/tags/macro/self_import.test | 17 +++++++ test/Twig/Tests/Fixtures/tags/set/basic.test | 17 +++++++ test/Twig/Tests/Fixtures/tags/set/capture.test | 10 ++++ test/Twig/Tests/Fixtures/tags/set/expression.test | 12 +++++ test/Twig/Tests/integrationTest.php | 2 +- test/fixtures/expressions/array.test | 49 -------------------- test/fixtures/expressions/array_call.test | 14 ------ test/fixtures/expressions/binary.test | 42 ----------------- test/fixtures/expressions/comparison.test | 16 ------ test/fixtures/expressions/dotdot.test | 17 ------- test/fixtures/expressions/grouping.test | 8 --- test/fixtures/expressions/in.test | 15 ------ test/fixtures/expressions/magic_call.test | 27 ----------- test/fixtures/expressions/method_call.test | 20 -------- test/fixtures/expressions/ternary_operator.test | 14 ------ test/fixtures/expressions/unary.test | 10 ---- test/fixtures/filters/cycle.test | 16 ------ test/fixtures/filters/date.test | 23 --------- test/fixtures/filters/default.test | 10 ---- test/fixtures/filters/even.test | 9 ---- test/fixtures/filters/format.test | 8 --- test/fixtures/filters/in.test | 27 ----------- test/fixtures/filters/length.test | 10 ---- test/fixtures/filters/odd.test | 10 ---- test/fixtures/filters/sort.test | 10 ---- test/fixtures/tags/autoescape/basic.test | 22 --------- test/fixtures/tags/autoescape/blocks.test | 12 ----- test/fixtures/tags/autoescape/double_escaping.test | 10 ---- test/fixtures/tags/autoescape/literal.test | 10 ---- test/fixtures/tags/autoescape/nested.test | 26 ---------- test/fixtures/tags/autoescape/objects.test | 19 -------- test/fixtures/tags/autoescape/safe.test | 10 ---- test/fixtures/tags/autoescape/strategy.test | 11 ---- test/fixtures/tags/autoescape/with_filters.test | 14 ------ .../tags/autoescape/with_filters_arguments.test | 20 -------- test/fixtures/tags/block/basic.test | 11 ---- test/fixtures/tags/filter/basic.test | 10 ---- test/fixtures/tags/filter/multiple.test | 10 ---- test/fixtures/tags/filter/nested.test | 16 ------ test/fixtures/tags/filter/with_for_tag.test | 13 ----- test/fixtures/tags/filter/with_if_tag.test | 29 ------------ test/fixtures/tags/for/context.test | 18 ------- test/fixtures/tags/for/else.test | 21 -------- test/fixtures/tags/for/inner_variables.test | 17 ------- test/fixtures/tags/for/keys.test | 11 ---- test/fixtures/tags/for/keys_and_values.test | 11 ---- test/fixtures/tags/for/loop_context.test | 19 -------- test/fixtures/tags/for/loop_context_local.test | 10 ---- test/fixtures/tags/for/nested_else.test | 17 ------- test/fixtures/tags/for/objects.test | 43 ----------------- test/fixtures/tags/for/objects_countable.test | 47 ------------------- test/fixtures/tags/for/recursive.test | 18 ------- test/fixtures/tags/for/values.test | 11 ---- test/fixtures/tags/if/basic.test | 22 --------- test/fixtures/tags/if/expression.test | 22 --------- test/fixtures/tags/include/basic.test | 16 ------ test/fixtures/tags/include/expression.test | 16 ------ test/fixtures/tags/include/template_instance.test | 10 ---- test/fixtures/tags/include/with_variables.test | 12 ----- test/fixtures/tags/inheritance/basic.test | 14 ------ test/fixtures/tags/inheritance/conditional.test | 14 ------ test/fixtures/tags/inheritance/dynamic.test | 14 ------ test/fixtures/tags/inheritance/multiple.test | 12 ----- test/fixtures/tags/inheritance/parent.test | 12 ----- test/fixtures/tags/inheritance/parent_nested.test | 27 ----------- .../tags/inheritance/template_instance.test | 14 ------ test/fixtures/tags/macro/basic.test | 15 ------ test/fixtures/tags/macro/external.test | 17 ------- test/fixtures/tags/macro/self_import.test | 17 ------- test/fixtures/tags/set/basic.test | 17 ------- test/fixtures/tags/set/capture.test | 10 ---- test/fixtures/tags/set/expression.test | 12 ----- 135 files changed, 1135 insertions(+), 1135 deletions(-) create mode 100644 test/Twig/Tests/Fixtures/expressions/array.test create mode 100644 test/Twig/Tests/Fixtures/expressions/array_call.test create mode 100644 test/Twig/Tests/Fixtures/expressions/binary.test create mode 100644 test/Twig/Tests/Fixtures/expressions/comparison.test create mode 100644 test/Twig/Tests/Fixtures/expressions/dotdot.test create mode 100644 test/Twig/Tests/Fixtures/expressions/grouping.test create mode 100644 test/Twig/Tests/Fixtures/expressions/in.test create mode 100644 test/Twig/Tests/Fixtures/expressions/magic_call.test create mode 100644 test/Twig/Tests/Fixtures/expressions/method_call.test create mode 100644 test/Twig/Tests/Fixtures/expressions/ternary_operator.test create mode 100644 test/Twig/Tests/Fixtures/expressions/unary.test create mode 100644 test/Twig/Tests/Fixtures/filters/cycle.test create mode 100644 test/Twig/Tests/Fixtures/filters/date.test create mode 100644 test/Twig/Tests/Fixtures/filters/default.test create mode 100644 test/Twig/Tests/Fixtures/filters/even.test create mode 100644 test/Twig/Tests/Fixtures/filters/format.test create mode 100644 test/Twig/Tests/Fixtures/filters/in.test create mode 100644 test/Twig/Tests/Fixtures/filters/length.test create mode 100644 test/Twig/Tests/Fixtures/filters/odd.test create mode 100644 test/Twig/Tests/Fixtures/filters/sort.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/blocks.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/literal.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/nested.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/objects.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/safe.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/strategy.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test create mode 100644 test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test create mode 100644 test/Twig/Tests/Fixtures/tags/block/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/filter/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/filter/multiple.test create mode 100644 test/Twig/Tests/Fixtures/tags/filter/nested.test create mode 100644 test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test create mode 100644 test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/context.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/else.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/inner_variables.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/keys.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/keys_and_values.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/loop_context.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/loop_context_local.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/nested_else.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/objects.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/objects_countable.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/recursive.test create mode 100644 test/Twig/Tests/Fixtures/tags/for/values.test create mode 100644 test/Twig/Tests/Fixtures/tags/if/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/if/expression.test create mode 100644 test/Twig/Tests/Fixtures/tags/include/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/include/expression.test create mode 100644 test/Twig/Tests/Fixtures/tags/include/template_instance.test create mode 100644 test/Twig/Tests/Fixtures/tags/include/with_variables.test create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/conditional.test create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/multiple.test create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/parent.test create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test create mode 100644 test/Twig/Tests/Fixtures/tags/macro/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/macro/external.test create mode 100644 test/Twig/Tests/Fixtures/tags/macro/self_import.test create mode 100644 test/Twig/Tests/Fixtures/tags/set/basic.test create mode 100644 test/Twig/Tests/Fixtures/tags/set/capture.test create mode 100644 test/Twig/Tests/Fixtures/tags/set/expression.test delete mode 100644 test/fixtures/expressions/array.test delete mode 100644 test/fixtures/expressions/array_call.test delete mode 100644 test/fixtures/expressions/binary.test delete mode 100644 test/fixtures/expressions/comparison.test delete mode 100644 test/fixtures/expressions/dotdot.test delete mode 100644 test/fixtures/expressions/grouping.test delete mode 100644 test/fixtures/expressions/in.test delete mode 100644 test/fixtures/expressions/magic_call.test delete mode 100644 test/fixtures/expressions/method_call.test delete mode 100644 test/fixtures/expressions/ternary_operator.test delete mode 100644 test/fixtures/expressions/unary.test delete mode 100644 test/fixtures/filters/cycle.test delete mode 100644 test/fixtures/filters/date.test delete mode 100644 test/fixtures/filters/default.test delete mode 100644 test/fixtures/filters/even.test delete mode 100644 test/fixtures/filters/format.test delete mode 100644 test/fixtures/filters/in.test delete mode 100644 test/fixtures/filters/length.test delete mode 100644 test/fixtures/filters/odd.test delete mode 100644 test/fixtures/filters/sort.test delete mode 100644 test/fixtures/tags/autoescape/basic.test delete mode 100644 test/fixtures/tags/autoescape/blocks.test delete mode 100644 test/fixtures/tags/autoescape/double_escaping.test delete mode 100644 test/fixtures/tags/autoescape/literal.test delete mode 100644 test/fixtures/tags/autoescape/nested.test delete mode 100644 test/fixtures/tags/autoescape/objects.test delete mode 100644 test/fixtures/tags/autoescape/safe.test delete mode 100644 test/fixtures/tags/autoescape/strategy.test delete mode 100644 test/fixtures/tags/autoescape/with_filters.test delete mode 100644 test/fixtures/tags/autoescape/with_filters_arguments.test delete mode 100644 test/fixtures/tags/block/basic.test delete mode 100644 test/fixtures/tags/filter/basic.test delete mode 100644 test/fixtures/tags/filter/multiple.test delete mode 100644 test/fixtures/tags/filter/nested.test delete mode 100644 test/fixtures/tags/filter/with_for_tag.test delete mode 100644 test/fixtures/tags/filter/with_if_tag.test delete mode 100644 test/fixtures/tags/for/context.test delete mode 100644 test/fixtures/tags/for/else.test delete mode 100644 test/fixtures/tags/for/inner_variables.test delete mode 100644 test/fixtures/tags/for/keys.test delete mode 100644 test/fixtures/tags/for/keys_and_values.test delete mode 100644 test/fixtures/tags/for/loop_context.test delete mode 100644 test/fixtures/tags/for/loop_context_local.test delete mode 100644 test/fixtures/tags/for/nested_else.test delete mode 100644 test/fixtures/tags/for/objects.test delete mode 100644 test/fixtures/tags/for/objects_countable.test delete mode 100644 test/fixtures/tags/for/recursive.test delete mode 100644 test/fixtures/tags/for/values.test delete mode 100644 test/fixtures/tags/if/basic.test delete mode 100644 test/fixtures/tags/if/expression.test delete mode 100644 test/fixtures/tags/include/basic.test delete mode 100644 test/fixtures/tags/include/expression.test delete mode 100644 test/fixtures/tags/include/template_instance.test delete mode 100644 test/fixtures/tags/include/with_variables.test delete mode 100644 test/fixtures/tags/inheritance/basic.test delete mode 100644 test/fixtures/tags/inheritance/conditional.test delete mode 100644 test/fixtures/tags/inheritance/dynamic.test delete mode 100644 test/fixtures/tags/inheritance/multiple.test delete mode 100644 test/fixtures/tags/inheritance/parent.test delete mode 100644 test/fixtures/tags/inheritance/parent_nested.test delete mode 100644 test/fixtures/tags/inheritance/template_instance.test delete mode 100644 test/fixtures/tags/macro/basic.test delete mode 100644 test/fixtures/tags/macro/external.test delete mode 100644 test/fixtures/tags/macro/self_import.test delete mode 100644 test/fixtures/tags/set/basic.test delete mode 100644 test/fixtures/tags/set/capture.test delete mode 100644 test/fixtures/tags/set/expression.test diff --git a/test/Twig/Tests/Fixtures/expressions/array.test b/test/Twig/Tests/Fixtures/expressions/array.test new file mode 100644 index 0000000..32f9fe2 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/array.test @@ -0,0 +1,49 @@ +--TEST-- +Twig supports array notation +--TEMPLATE-- +{# empty array #} +{{ []|join(',') }} + +{{ [1, 2]|join(',') }} +{{ ['foo', "bar"]|join(',') }} +{{ [1, 'foo': 'bar']|join(',') }} +{{ [1, 'foo': 'bar']|keys|join(',') }} + +{# nested arrays #} +{% set a = [1, 2, [1, 2], 'foo': ['foo': 'bar']] %} +{{ a[2]|join(',') }} +{{ a["foo"]|join(',') }} + +{# works even if [] is used inside the array #} +{{ [foo[bar]]|join(',') }} + +{# elements can be any expression #} +{{ ['foo'|upper, bar|upper, bar == foo]|join(',') }} + +{# arrays can have a trailing , like in PHP #} +{{ + [ + 1, + 2, + ]|join(',') +}} +--DATA-- +return array('bar' => 'bar', 'foo' => array('bar' => 'bar')) +--EXPECT-- +1,2 +foo,bar +1,bar +0,foo + + +1,2 +bar + + +bar + + +FOO,BAR, + + +1,2 diff --git a/test/Twig/Tests/Fixtures/expressions/array_call.test b/test/Twig/Tests/Fixtures/expressions/array_call.test new file mode 100644 index 0000000..f3df328 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/array_call.test @@ -0,0 +1,14 @@ +--TEST-- +Twig supports method calls +--TEMPLATE-- +{{ items.foo }} +{{ items['foo'] }} +{{ items[foo] }} +{{ items[items[foo]] }} +--DATA-- +return array('foo' => 'bar', 'items' => array('foo' => 'bar', 'bar' => 'foo')) +--EXPECT-- +bar +bar +foo +bar diff --git a/test/Twig/Tests/Fixtures/expressions/binary.test b/test/Twig/Tests/Fixtures/expressions/binary.test new file mode 100644 index 0000000..009c8c8 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/binary.test @@ -0,0 +1,42 @@ +--TEST-- +Twig supports binary operations (+, -, *, /, ~, %, and, or) +--TEMPLATE-- +{{ 1 + 1 }} +{{ 2 - 1 }} +{{ 2 * 2 }} +{{ 2 / 2 }} +{{ 3 % 2 }} +{{ 1 and 1 }} +{{ 1 and 0 }} +{{ 0 and 1 }} +{{ 0 and 0 }} +{{ 1 or 1 }} +{{ 1 or 0 }} +{{ 0 or 1 }} +{{ 0 or 0 }} +{{ "foo" ~ "bar" }} +{{ foo ~ "bar" }} +{{ "foo" ~ bar }} +{{ foo ~ bar }} +{{ 20 // 7 }} +--DATA-- +return array('foo' => 'bar', 'bar' => 'foo') +--EXPECT-- +2 +1 +4 +1 +1 +1 + + + +1 +1 +1 + +foobar +barbar +foofoo +barfoo +2 diff --git a/test/Twig/Tests/Fixtures/expressions/comparison.test b/test/Twig/Tests/Fixtures/expressions/comparison.test new file mode 100644 index 0000000..4ed77e5 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/comparison.test @@ -0,0 +1,16 @@ +--TEST-- +Twig supports comparison operators (==, !=, <, >, >=, <=) +--TEMPLATE-- +{{ 1 > 2 }}/{{ 1 > 1 }}/{{ 1 >= 2 }}/{{ 1 >= 1 }} +{{ 1 < 2 }}/{{ 1 < 1 }}/{{ 1 <= 2 }}/{{ 1 <= 1 }} +{{ 1 == 1 }}/{{ 1 == 2 }} +{{ 1 != 1 }}/{{ 1 != 2 }} +{{ 1 < 2 < 3 }}/{{ 1 < 2 < 3 < 4 }} +--DATA-- +return array() +--EXPECT-- +///1 +1//1/1 +1/ +/1 +1/1 diff --git a/test/Twig/Tests/Fixtures/expressions/dotdot.test b/test/Twig/Tests/Fixtures/expressions/dotdot.test new file mode 100644 index 0000000..b3ee396 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/dotdot.test @@ -0,0 +1,17 @@ +--TEST-- +Twig supports the .. operator +--TEMPLATE-- +{% for i in 0..10 %}{{ i }} {% endfor %} + +{% for letter in 'a'..'z' %}{{ letter }} {% endfor %} + +{% for letter in 'a'|upper..'z'|upper %}{{ letter }} {% endfor %} + +{% for i in foo[0]..foo[1] %}{{ i }} {% endfor %} +--DATA-- +return array('foo' => array(1, 10)) +--EXPECT-- +0 1 2 3 4 5 6 7 8 9 10 +a b c d e f g h i j k l m n o p q r s t u v w x y z +A B C D E F G H I J K L M N O P Q R S T U V W X Y Z +1 2 3 4 5 6 7 8 9 10 diff --git a/test/Twig/Tests/Fixtures/expressions/grouping.test b/test/Twig/Tests/Fixtures/expressions/grouping.test new file mode 100644 index 0000000..79f8e0b --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/grouping.test @@ -0,0 +1,8 @@ +--TEST-- +Twig supports grouping of expressions +--TEMPLATE-- +{{ (2 + 2) / 2 }} +--DATA-- +return array() +--EXPECT-- +2 diff --git a/test/Twig/Tests/Fixtures/expressions/in.test b/test/Twig/Tests/Fixtures/expressions/in.test new file mode 100644 index 0000000..344a97e --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/in.test @@ -0,0 +1,15 @@ +--TEST-- +Twig supports the in operator +--TEMPLATE-- +{% if bar in foo %} +TRUE +{% endif %} +{% if not bar in foo %} +{% else %} +TRUE +{% endif %} +--DATA-- +return array('bar' => 'bar', 'foo' => array('bar' => 'bar')) +--EXPECT-- +TRUE +TRUE diff --git a/test/Twig/Tests/Fixtures/expressions/magic_call.test b/test/Twig/Tests/Fixtures/expressions/magic_call.test new file mode 100644 index 0000000..159db96 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/magic_call.test @@ -0,0 +1,27 @@ +--TEST-- +Twig supports __call() for attributes +--TEMPLATE-- +{{ foo.foo }} +{{ foo.bar }} +--DATA-- +class TestClassForMagicCallAttributes +{ + public function getBar() + { + return 'bar_from_getbar'; + } + + public function __call($method, $arguments) + { + if ('foo' === $method) + { + return 'foo_from_call'; + } + + return false; + } +} +return array('foo' => new TestClassForMagicCallAttributes()) +--EXPECT-- +foo_from_call +bar_from_getbar diff --git a/test/Twig/Tests/Fixtures/expressions/method_call.test b/test/Twig/Tests/Fixtures/expressions/method_call.test new file mode 100644 index 0000000..14674b8 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/method_call.test @@ -0,0 +1,20 @@ +--TEST-- +Twig supports method calls +--TEMPLATE-- +{{ items.foo.foo }} +{{ items.foo.getFoo() }} +{{ items.foo.bar }} +{{ items.foo['bar'] }} +{{ items.foo.bar('a', 43) }} +{{ items.foo.bar(foo) }} +{{ items.foo.self.foo() }} +--DATA-- +return array('foo' => 'bar', 'items' => array('foo' => new Foo(), 'bar' => 'foo')) +--EXPECT-- +foo +foo +bar + +bar_a-43 +bar_bar +foo diff --git a/test/Twig/Tests/Fixtures/expressions/ternary_operator.test b/test/Twig/Tests/Fixtures/expressions/ternary_operator.test new file mode 100644 index 0000000..cbf555c --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/ternary_operator.test @@ -0,0 +1,14 @@ +--TEST-- +Twig supports the ternary operator +--TEMPLATE-- +{{ 1 ? 'YES' : 'NO' }} +{{ 0 ? 'YES' : 'NO' }} +{{ 0 ? 'YES' : (1 ? 'YES1' : 'NO1') }} +{{ 0 ? 'YES' : (0 ? 'YES1' : 'NO1') }} +--DATA-- +return array() +--EXPECT-- +YES +NO +YES1 +NO1 diff --git a/test/Twig/Tests/Fixtures/expressions/unary.test b/test/Twig/Tests/Fixtures/expressions/unary.test new file mode 100644 index 0000000..2e1cb35 --- /dev/null +++ b/test/Twig/Tests/Fixtures/expressions/unary.test @@ -0,0 +1,10 @@ +--TEST-- +Twig supports unary operators (not, -, +) +--TEMPLATE-- +{{ not 1 }}/{{ not 0 }} +{{ +1 + 1 }}/{{ -1 - 1 }} +--DATA-- +return array() +--EXPECT-- +/1 +2/-2 diff --git a/test/Twig/Tests/Fixtures/filters/cycle.test b/test/Twig/Tests/Fixtures/filters/cycle.test new file mode 100644 index 0000000..d136833 --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/cycle.test @@ -0,0 +1,16 @@ +--TEST-- +"cycle" filter +--TEMPLATE-- +{% for i in 0..6 %} +{{ array1|cycle(i) }}-{{ array2|cycle(i) }} +{% endfor %} +--DATA-- +return array('array1' => array('odd', 'even'), 'array2' => array('apple', 'orange', 'citrus')) +--EXPECT-- +odd-apple +even-orange +odd-citrus +even-apple +odd-orange +even-citrus +odd-apple diff --git a/test/Twig/Tests/Fixtures/filters/date.test b/test/Twig/Tests/Fixtures/filters/date.test new file mode 100644 index 0000000..21b57ba --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/date.test @@ -0,0 +1,23 @@ +--TEST-- +"date" filter +--TEMPLATE-- +{{ date1|date }} +{{ date1|date('d/m/Y') }} +{{ date2|date }} +{{ date2|date('d/m/Y') }} +{{ date3|date }} +{{ date3|date('d/m/Y') }} +{{ date4|date }} +{{ date4|date('d/m/Y') }} +--DATA-- +date_default_timezone_set('UTC'); +return array('date1' => mktime(13, 45, 0, 10, 4, 2010), 'date2' => new DateTime('2010-10-04 13:45'), 'date3' => '2010-10-04 13:45', 'date4' => 1286199900) +--EXPECT-- +October 4, 2010 13:45 +04/10/2010 +October 4, 2010 13:45 +04/10/2010 +October 4, 2010 13:45 +04/10/2010 +October 4, 2010 13:45 +04/10/2010 diff --git a/test/Twig/Tests/Fixtures/filters/default.test b/test/Twig/Tests/Fixtures/filters/default.test new file mode 100644 index 0000000..8fd8017 --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/default.test @@ -0,0 +1,10 @@ +--TEST-- +"default" filter +--TEMPLATE-- +{{ foo|default('bar') }} +{{ bar|default('foo') }} +--DATA-- +return array('foo' => null, 'bar' => 'bar') +--EXPECT-- +bar +bar diff --git a/test/Twig/Tests/Fixtures/filters/even.test b/test/Twig/Tests/Fixtures/filters/even.test new file mode 100644 index 0000000..835bb79 --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/even.test @@ -0,0 +1,9 @@ +--TEST-- +"even" filter +--TEMPLATE-- +{{ 1|even }} +{{ 2|even }} +--DATA-- +return array() +--EXPECT-- +1 diff --git a/test/Twig/Tests/Fixtures/filters/format.test b/test/Twig/Tests/Fixtures/filters/format.test new file mode 100644 index 0000000..97221ff --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/format.test @@ -0,0 +1,8 @@ +--TEST-- +"format" filter +--TEMPLATE-- +{{ string|format(foo, 3) }} +--DATA-- +return array('string' => '%s/%d', 'foo' => 'bar') +--EXPECT-- +bar/3 diff --git a/test/Twig/Tests/Fixtures/filters/in.test b/test/Twig/Tests/Fixtures/filters/in.test new file mode 100644 index 0000000..4d6e337 --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/in.test @@ -0,0 +1,27 @@ +--TEST-- +"in" filter +--TEMPLATE-- +{{ 1|in([1, 2, 3]) }} +{{ 5|in([1, 2, 3]) }} +{{ 'cd'|in('abcde') }} +{{ 'ad'|in('abcde') }} +{{ 'foo'|in(foo) }} +{{ 'a'|in(foo|keys) }} +--DATA-- +class ItemsIteratorForInFilter implements Iterator +{ + protected $values = array('a' => 'foo', 'b' => 'bar'); + public function current() { return current($this->values); } + public function key() { return key($this->values); } + public function next() { return next($this->values); } + public function rewind() { return reset($this->values); } + public function valid() { return false !== current($this->values); } +} +return array('foo' => new ItemsIteratorForInFilter()) +--EXPECT-- +1 + +1 + +1 +1 diff --git a/test/Twig/Tests/Fixtures/filters/length.test b/test/Twig/Tests/Fixtures/filters/length.test new file mode 100644 index 0000000..b5ef879 --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/length.test @@ -0,0 +1,10 @@ +--TEST-- +"length" filter +--TEMPLATE-- +{{ array|length }} +{{ string|length }} +--DATA-- +return array('array' => array(1, 4), 'string' => 'foo') +--EXPECT-- +2 +3 diff --git a/test/Twig/Tests/Fixtures/filters/odd.test b/test/Twig/Tests/Fixtures/filters/odd.test new file mode 100644 index 0000000..1de0351 --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/odd.test @@ -0,0 +1,10 @@ +--TEST-- +"odd" filter +--TEMPLATE-- +{{ 1|odd }} +{{ 2|odd }} +--DATA-- +return array() +--EXPECT-- + +1 diff --git a/test/Twig/Tests/Fixtures/filters/sort.test b/test/Twig/Tests/Fixtures/filters/sort.test new file mode 100644 index 0000000..21d575f --- /dev/null +++ b/test/Twig/Tests/Fixtures/filters/sort.test @@ -0,0 +1,10 @@ +--TEST-- +"sort" filter +--TEMPLATE-- +{{ array1|sort|join }} +{{ array2|sort|join }} +--DATA-- +return array('array1' => array(4, 1), 'array2' => array('foo', 'bar')) +--EXPECT-- +14 +barfoo diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/basic.test b/test/Twig/Tests/Fixtures/tags/autoescape/basic.test new file mode 100644 index 0000000..6f6c1b9 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/basic.test @@ -0,0 +1,22 @@ +--TEST-- +"autoescape" tag applies escaping on its children +--TEMPLATE-- +{% autoescape on %} +{{ var }}
+{% endautoescape %} +{% autoescape off %} +{{ var }}
+{% endautoescape %} +{% autoescape on %} +{{ var }}
+{% endautoescape %} +{% autoescape off %} +{{ var }}
+{% endautoescape %} +--DATA-- +return array('var' => '
') +--EXPECT-- +<br />
+

+<br />
+

diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test b/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test new file mode 100644 index 0000000..8e05761 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test @@ -0,0 +1,12 @@ +--TEST-- +"autoescape" tag applies escaping on embedded blocks +--TEMPLATE-- +{% autoescape on %} + {% block foo %} + {{ var }} + {% endblock %} +{% endautoescape %} +--DATA-- +return array('var' => '
') +--EXPECT-- +<br /> diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test b/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test new file mode 100644 index 0000000..fc7aa8c --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test @@ -0,0 +1,10 @@ +--TEST-- +"autoescape" tag does not double-escape +--TEMPLATE-- +{% autoescape on %} +{{ var|escape }} +{% endautoescape %} +--DATA-- +return array('var' => '
') +--EXPECT-- +<br /> diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/literal.test b/test/Twig/Tests/Fixtures/tags/autoescape/literal.test new file mode 100644 index 0000000..4c25706 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/literal.test @@ -0,0 +1,10 @@ +--TEST-- +"autoescape" tag does not apply escaping on literals +--TEMPLATE-- +{% autoescape on %} +{{ "
" }} +{% endautoescape %} +--DATA-- +return array() +--EXPECT-- +
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/nested.test b/test/Twig/Tests/Fixtures/tags/autoescape/nested.test new file mode 100644 index 0000000..49f4da9 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/nested.test @@ -0,0 +1,26 @@ +--TEST-- +"autoescape" tags can be nested at will +--TEMPLATE-- +{{ var }} +{% autoescape on %} + {{ var }} + {% autoescape off %} + {{ var }} + {% autoescape on %} + {{ var }} + {% endautoescape %} + {{ var }} + {% endautoescape %} + {{ var }} +{% endautoescape %} +{{ var }} +--DATA-- +return array('var' => '
') +--EXPECT-- +<br /> + <br /> +
+ <br /> +
+ <br /> +<br /> diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/objects.test b/test/Twig/Tests/Fixtures/tags/autoescape/objects.test new file mode 100644 index 0000000..44f41e1 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/objects.test @@ -0,0 +1,19 @@ +--TEST-- +"autoescape" tag applies escaping to object method calls +--TEMPLATE-- +{% autoescape on %} +{{ user.name }} +{{ user.name|lower }} +{% endautoescape %} +--DATA-- +class UserForAutoEscapeTest +{ + public function getName() + { + return 'Fabien
'; + } +} +return array('user' => new UserForAutoEscapeTest()) +--EXPECT-- +Fabien<br /> +fabien<br /> diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/safe.test b/test/Twig/Tests/Fixtures/tags/autoescape/safe.test new file mode 100644 index 0000000..9c45c0e --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/safe.test @@ -0,0 +1,10 @@ +--TEST-- +"autoescape" tag does not escape when safe is used as a filter +--TEMPLATE-- +{% autoescape on %} +{{ var|safe }} +{% endautoescape %} +--DATA-- +return array('var' => '
') +--EXPECT-- +
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test b/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test new file mode 100644 index 0000000..f3e09dd --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test @@ -0,0 +1,11 @@ +--TEST-- +"autoescape" tag accepts an escaping strategy +--TEMPLATE-- +{% autoescape on js %}{{ var }}{% endautoescape %} + +{% autoescape on html %}{{ var }}{% endautoescape %} +--DATA-- +return array('var' => '
"') +--EXPECT-- +
\" +<br />" diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test new file mode 100644 index 0000000..3bb0dd4 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test @@ -0,0 +1,14 @@ +--TEST-- +"autoescape" tag applies escaping before calling filters +--TEMPLATE-- +{% autoescape on %} +{{ var|nl2br }} +{{ var|nl2br|escape }} +{% endautoescape %} +--DATA-- +return array('var' => "\nTwig") +--EXPECT-- +<Fabien>
+Twig +<Fabien><br /> +Twig diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test new file mode 100644 index 0000000..54cbe99 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test @@ -0,0 +1,20 @@ +--TEST-- +"autoescape" tag applies escaping on filter arguments, but not on literals +--TEMPLATE-- +{% autoescape on %} +{{ var|nl2br("
") }} +{{ var|nl2br("
"|escape) }} +{{ var|nl2br(sep) }} +{{ var|nl2br(sep|safe) }} +{% endautoescape %} +--DATA-- +return array('var' => "\nTwig", 'sep' => '
') +--EXPECT-- +<Fabien>
+Twig +<Fabien><br /> +Twig +<Fabien><br /> +Twig +<Fabien>
+Twig diff --git a/test/Twig/Tests/Fixtures/tags/block/basic.test b/test/Twig/Tests/Fixtures/tags/block/basic.test new file mode 100644 index 0000000..360dcf0 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/block/basic.test @@ -0,0 +1,11 @@ +--TEST-- +"block" tag +--TEMPLATE-- +{% block title1 %}FOO{% endblock %} +{% block title2 foo|lower %} +--TEMPLATE(foo.twig)-- +{% block content %}{% endblock %} +--DATA-- +return array('foo' => 'bar') +--EXPECT-- +FOObar diff --git a/test/Twig/Tests/Fixtures/tags/filter/basic.test b/test/Twig/Tests/Fixtures/tags/filter/basic.test new file mode 100644 index 0000000..82094f2 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/filter/basic.test @@ -0,0 +1,10 @@ +--TEST-- +"filter" tag applies a filter on its children +--TEMPLATE-- +{% filter upper %} +Some text with a {{ var }} +{% endfilter %} +--DATA-- +return array('var' => 'var') +--EXPECT-- +SOME TEXT WITH A VAR diff --git a/test/Twig/Tests/Fixtures/tags/filter/multiple.test b/test/Twig/Tests/Fixtures/tags/filter/multiple.test new file mode 100644 index 0000000..75512ef --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/filter/multiple.test @@ -0,0 +1,10 @@ +--TEST-- +"filter" tags accept multiple chained filters +--TEMPLATE-- +{% filter lower|title %} + {{ var }} +{% endfilter %} +--DATA-- +return array('var' => 'VAR') +--EXPECT-- + Var diff --git a/test/Twig/Tests/Fixtures/tags/filter/nested.test b/test/Twig/Tests/Fixtures/tags/filter/nested.test new file mode 100644 index 0000000..7e4e4eb --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/filter/nested.test @@ -0,0 +1,16 @@ +--TEST-- +"filter" tags can be nested at will +--TEMPLATE-- +{% filter lower|title %} + {{ var }} + {% filter upper %} + {{ var }} + {% endfilter %} + {{ var }} +{% endfilter %} +--DATA-- +return array('var' => 'var') +--EXPECT-- + Var + Var + Var diff --git a/test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test b/test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test new file mode 100644 index 0000000..22745ea --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test @@ -0,0 +1,13 @@ +--TEST-- +"filter" tag applies the filter on "for" tags +--TEMPLATE-- +{% filter upper %} +{% for item in items %} +{{ item }} +{% endfor %} +{% endfilter %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- +A +B diff --git a/test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test b/test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test new file mode 100644 index 0000000..02381dd --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test @@ -0,0 +1,29 @@ +--TEST-- +"filter" tag applies the filter on "if" tags +--TEMPLATE-- +{% filter upper %} +{% if items %} +{{ items|join(', ') }} +{% endif %} + +{% if items.3 %} +FOO +{% else %} +{{ items.1 }} +{% endif %} + +{% if items.3 %} +FOO +{% elseif items.1 %} +{{ items.0 }} +{% endif %} + +{% endfilter %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- +A, B + +B + +A diff --git a/test/Twig/Tests/Fixtures/tags/for/context.test b/test/Twig/Tests/Fixtures/tags/for/context.test new file mode 100644 index 0000000..ddc6930 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/context.test @@ -0,0 +1,18 @@ +--TEST-- +"for" tag keeps the context safe +--TEMPLATE-- +{% for item in items %} + {% for item in items %} + * {{ item }} + {% endfor %} + * {{ item }} +{% endfor %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- + * a + * b + * a + * a + * b + * b diff --git a/test/Twig/Tests/Fixtures/tags/for/else.test b/test/Twig/Tests/Fixtures/tags/for/else.test new file mode 100644 index 0000000..8c6a7d2 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/else.test @@ -0,0 +1,21 @@ +--TEST-- +"for" tag can use an "else" clause +--TEMPLATE-- +{% for item in items %} + * {{ item }} +{% else %} + no item +{% endfor %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- + * a + * b +--DATA-- +return array('items' => array()) +--EXPECT-- + no item +--DATA-- +return array() +--EXPECT-- + no item diff --git a/test/Twig/Tests/Fixtures/tags/for/inner_variables.test b/test/Twig/Tests/Fixtures/tags/for/inner_variables.test new file mode 100644 index 0000000..49fb9ca --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/inner_variables.test @@ -0,0 +1,17 @@ +--TEST-- +"for" tag does not reset inner variables +--TEMPLATE-- +{% for i in 1..2 %} + {% for j in 0..2 %} + {{k}}{% set k = k+1 %} {{ loop.parent.loop.index }} + {% endfor %} +{% endfor %} +--DATA-- +return array('k' => 0) +--EXPECT-- + 0 1 + 1 1 + 2 1 + 3 2 + 4 2 + 5 2 diff --git a/test/Twig/Tests/Fixtures/tags/for/keys.test b/test/Twig/Tests/Fixtures/tags/for/keys.test new file mode 100644 index 0000000..4e22cb4 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/keys.test @@ -0,0 +1,11 @@ +--TEST-- +"for" tag can iterate over keys +--TEMPLATE-- +{% for key in items|keys %} + * {{ key }} +{% endfor %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- + * 0 + * 1 diff --git a/test/Twig/Tests/Fixtures/tags/for/keys_and_values.test b/test/Twig/Tests/Fixtures/tags/for/keys_and_values.test new file mode 100644 index 0000000..4c21168 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/keys_and_values.test @@ -0,0 +1,11 @@ +--TEST-- +"for" tag can iterate over keys and values +--TEMPLATE-- +{% for key, item in items %} + * {{ key }}/{{ item }} +{% endfor %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- + * 0/a + * 1/b diff --git a/test/Twig/Tests/Fixtures/tags/for/loop_context.test b/test/Twig/Tests/Fixtures/tags/for/loop_context.test new file mode 100644 index 0000000..93bc76a --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/loop_context.test @@ -0,0 +1,19 @@ +--TEST-- +"for" tag adds a loop variable to the context +--TEMPLATE-- +{% for item in items %} + * {{ loop.index }}/{{ loop.index0 }} + * {{ loop.revindex }}/{{ loop.revindex0 }} + * {{ loop.first }}/{{ loop.last }}/{{ loop.length }} + +{% endfor %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- + * 1/0 + * 2/1 + * 1//2 + + * 2/1 + * 1/0 + * /1/2 diff --git a/test/Twig/Tests/Fixtures/tags/for/loop_context_local.test b/test/Twig/Tests/Fixtures/tags/for/loop_context_local.test new file mode 100644 index 0000000..4ec5440 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/loop_context_local.test @@ -0,0 +1,10 @@ +--TEST-- +"for" tag adds a loop variable to the context locally +--TEMPLATE-- +{% for item in items %} +{% endfor %} +{% if not loop %}WORKS{% endif %} +--DATA-- +return array('items' => array()) +--EXPECT-- +WORKS diff --git a/test/Twig/Tests/Fixtures/tags/for/nested_else.test b/test/Twig/Tests/Fixtures/tags/for/nested_else.test new file mode 100644 index 0000000..f8b9f6b --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/nested_else.test @@ -0,0 +1,17 @@ +--TEST-- +"for" tag can use an "else" clause +--TEMPLATE-- +{% for item in items %} + {% for item in items1 %} + * {{ item }} + {% else %} + no {{ item }} + {% endfor %} +{% else %} + no item1 +{% endfor %} +--DATA-- +return array('items' => array('a', 'b'), 'items1' => array()) +--EXPECT-- +no a + no b diff --git a/test/Twig/Tests/Fixtures/tags/for/objects.test b/test/Twig/Tests/Fixtures/tags/for/objects.test new file mode 100644 index 0000000..5034437 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/objects.test @@ -0,0 +1,43 @@ +--TEST-- +"for" tag iterates over iterable objects +--TEMPLATE-- +{% for item in items %} + * {{ item }} + * {{ loop.index }}/{{ loop.index0 }} + * {{ loop.first }} + +{% endfor %} + +{% for key, value in items %} + * {{ key }}/{{ value }} +{% endfor %} + +{% for key in items|keys %} + * {{ key }} +{% endfor %} +--DATA-- +class ItemsIterator implements Iterator +{ + protected $values = array('foo' => 'bar', 'bar' => 'foo'); + public function current() { return current($this->values); } + public function key() { return key($this->values); } + public function next() { return next($this->values); } + public function rewind() { return reset($this->values); } + public function valid() { return false !== current($this->values); } +} +return array('items' => new ItemsIterator()) +--EXPECT-- + * bar + * 1/0 + * 1 + + * foo + * 2/1 + * + + + * foo/bar + * bar/foo + + * foo + * bar diff --git a/test/Twig/Tests/Fixtures/tags/for/objects_countable.test b/test/Twig/Tests/Fixtures/tags/for/objects_countable.test new file mode 100644 index 0000000..4a1ff61 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/objects_countable.test @@ -0,0 +1,47 @@ +--TEST-- +"for" tag iterates over iterable and countable objects +--TEMPLATE-- +{% for item in items %} + * {{ item }} + * {{ loop.index }}/{{ loop.index0 }} + * {{ loop.revindex }}/{{ loop.revindex0 }} + * {{ loop.first }}/{{ loop.last }}/{{ loop.length }} + +{% endfor %} + +{% for key, value in items %} + * {{ key }}/{{ value }} +{% endfor %} + +{% for key in items|keys %} + * {{ key }} +{% endfor %} +--DATA-- +class ItemsIteratorCountable implements Iterator, Countable +{ + protected $values = array('foo' => 'bar', 'bar' => 'foo'); + public function current() { return current($this->values); } + public function key() { return key($this->values); } + public function next() { return next($this->values); } + public function rewind() { return reset($this->values); } + public function valid() { return false !== current($this->values); } + public function count() { return count($this->values); } +} +return array('items' => new ItemsIteratorCountable()) +--EXPECT-- + * bar + * 1/0 + * 2/1 + * 1//2 + + * foo + * 2/1 + * 1/0 + * /1/2 + + + * foo/bar + * bar/foo + + * foo + * bar diff --git a/test/Twig/Tests/Fixtures/tags/for/recursive.test b/test/Twig/Tests/Fixtures/tags/for/recursive.test new file mode 100644 index 0000000..17b2e22 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/recursive.test @@ -0,0 +1,18 @@ +--TEST-- +"for" tags can be nested +--TEMPLATE-- +{% for key, item in items %} +* {{ key }} ({{ loop.length }}): +{% for value in item %} + * {{ value }} ({{ loop.length }}) +{% endfor %} +{% endfor %} +--DATA-- +return array('items' => array('a' => array('a1', 'a2', 'a3'), 'b' => array('b1'))) +--EXPECT-- +* a (2): + * a1 (3) + * a2 (3) + * a3 (3) +* b (2): + * b1 (1) diff --git a/test/Twig/Tests/Fixtures/tags/for/values.test b/test/Twig/Tests/Fixtures/tags/for/values.test new file mode 100644 index 0000000..82f2ae8 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/for/values.test @@ -0,0 +1,11 @@ +--TEST-- +"for" tag iterates over item values +--TEMPLATE-- +{% for item in items %} + * {{ item }} +{% endfor %} +--DATA-- +return array('items' => array('a', 'b')) +--EXPECT-- + * a + * b diff --git a/test/Twig/Tests/Fixtures/tags/if/basic.test b/test/Twig/Tests/Fixtures/tags/if/basic.test new file mode 100644 index 0000000..2482ddf --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/if/basic.test @@ -0,0 +1,22 @@ +--TEST-- +"if" creates a condition +--TEMPLATE-- +{% if a %} + {{ a }} +{% elseif b %} + {{ b }} +{% else %} + NOTHING +{% endif %} +--DATA-- +return array('a' => 'a') +--EXPECT-- + a +--DATA-- +return array('b' => 'b') +--EXPECT-- + b +--DATA-- +return array() +--EXPECT-- + NOTHING diff --git a/test/Twig/Tests/Fixtures/tags/if/expression.test b/test/Twig/Tests/Fixtures/tags/if/expression.test new file mode 100644 index 0000000..edfb73d --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/if/expression.test @@ -0,0 +1,22 @@ +--TEST-- +"if" takes an expression as a test +--TEMPLATE-- +{% if a < 2 %} + A1 +{% elseif a > 10 %} + A2 +{% else %} + A3 +{% endif %} +--DATA-- +return array('a' => 1) +--EXPECT-- + A1 +--DATA-- +return array('a' => 12) +--EXPECT-- + A2 +--DATA-- +return array('a' => 7) +--EXPECT-- + A3 diff --git a/test/Twig/Tests/Fixtures/tags/include/basic.test b/test/Twig/Tests/Fixtures/tags/include/basic.test new file mode 100644 index 0000000..8fe1a6c --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/include/basic.test @@ -0,0 +1,16 @@ +--TEST-- +"include" tag +--TEMPLATE-- +FOO +{% include "foo.twig" %} + +BAR +--TEMPLATE(foo.twig)-- +FOOBAR +--DATA-- +return array() +--EXPECT-- +FOO + +FOOBAR +BAR diff --git a/test/Twig/Tests/Fixtures/tags/include/expression.test b/test/Twig/Tests/Fixtures/tags/include/expression.test new file mode 100644 index 0000000..eaeeb11 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/include/expression.test @@ -0,0 +1,16 @@ +--TEST-- +"include" tag allows expressions for the template to include +--TEMPLATE-- +FOO +{% include foo %} + +BAR +--TEMPLATE(foo.twig)-- +FOOBAR +--DATA-- +return array('foo' => 'foo.twig') +--EXPECT-- +FOO + +FOOBAR +BAR diff --git a/test/Twig/Tests/Fixtures/tags/include/template_instance.test b/test/Twig/Tests/Fixtures/tags/include/template_instance.test new file mode 100644 index 0000000..6ba064a --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/include/template_instance.test @@ -0,0 +1,10 @@ +--TEST-- +"include" tag accepts Twig_Template instance +--TEMPLATE-- +{% include foo %} FOO +--TEMPLATE(foo.twig)-- +BAR +--DATA-- +return array('foo' => $twig->loadTemplate('foo.twig')) +--EXPECT-- +BAR FOO diff --git a/test/Twig/Tests/Fixtures/tags/include/with_variables.test b/test/Twig/Tests/Fixtures/tags/include/with_variables.test new file mode 100644 index 0000000..96e393c --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/include/with_variables.test @@ -0,0 +1,12 @@ +--TEST-- +"include" tag accept variables +--TEMPLATE-- +{% include "foo.twig" with ['foo': 'bar'] %} +{% include "foo.twig" with vars %} +--TEMPLATE(foo.twig)-- +{{ foo }} +--DATA-- +return array('vars' => array('foo' => 'bar')) +--EXPECT-- +bar +bar diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/basic.test b/test/Twig/Tests/Fixtures/tags/inheritance/basic.test new file mode 100644 index 0000000..0778a4b --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/basic.test @@ -0,0 +1,14 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends "foo.twig" %} + +{% block content %} +FOO +{% endblock %} +--TEMPLATE(foo.twig)-- +{% block content %}{% endblock %} +--DATA-- +return array() +--EXPECT-- +FOO diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/conditional.test b/test/Twig/Tests/Fixtures/tags/inheritance/conditional.test new file mode 100644 index 0000000..3be8c47 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/conditional.test @@ -0,0 +1,14 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends standalone ? foo : 'bar.twig' %} + +{% block content %}{% parent %}FOO{% endblock %} +--TEMPLATE(foo.twig)-- +{% block content %}FOO{% endblock %} +--TEMPLATE(bar.twig)-- +{% block content %}BAR{% endblock %} +--DATA-- +return array('foo' => 'foo.twig', 'standalone' => true) +--EXPECT-- +FOOFOO diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test b/test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test new file mode 100644 index 0000000..ee06ddc --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test @@ -0,0 +1,14 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends foo %} + +{% block content %} +FOO +{% endblock %} +--TEMPLATE(foo.twig)-- +{% block content %}{% endblock %} +--DATA-- +return array('foo' => 'foo.twig') +--EXPECT-- +FOO diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/multiple.test b/test/Twig/Tests/Fixtures/tags/inheritance/multiple.test new file mode 100644 index 0000000..4aba998 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/multiple.test @@ -0,0 +1,12 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends "layout.twig" %}{% block content %}{% parent %}index {% endblock %} +--TEMPLATE(layout.twig)-- +{% extends "base.twig" %}{% block content %}{% parent %}layout {% endblock %} +--TEMPLATE(base.twig)-- +{% block content %}base {% endblock %} +--DATA-- +return array() +--EXPECT-- +base layout index diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/parent.test b/test/Twig/Tests/Fixtures/tags/inheritance/parent.test new file mode 100644 index 0000000..b4a1daf --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/parent.test @@ -0,0 +1,12 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends "foo.twig" %} + +{% block content %}{% parent %}FOO{% parent %}{% endblock %} +--TEMPLATE(foo.twig)-- +{% block content %}BAR{% endblock %} +--DATA-- +return array() +--EXPECT-- +BARFOOBAR diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test b/test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test new file mode 100644 index 0000000..1a5cf44 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test @@ -0,0 +1,27 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends "foo.twig" %} + +{% block content %} + {% block inside %} + INSIDE OVERRIDDEN + {% endblock %} + + BEFORE + {% parent %} + AFTER +{% endblock %} +--TEMPLATE(foo.twig)-- +{% block content %} + BAR +{% endblock %} +--DATA-- +return array() +--EXPECT-- + +INSIDE OVERRIDDEN + + BEFORE + BAR + AFTER diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test b/test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test new file mode 100644 index 0000000..b2c48d9 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test @@ -0,0 +1,14 @@ +--TEST-- +"extends" tag accepts Twig_Template instance +--TEMPLATE-- +{% extends foo %} + +{% block content %} +{% parent %}FOO +{% endblock %} +--TEMPLATE(foo.twig)-- +{% block content %}BAR{% endblock %} +--DATA-- +return array('foo' => $twig->loadTemplate('foo.twig')) +--EXPECT-- +BARFOO diff --git a/test/Twig/Tests/Fixtures/tags/macro/basic.test b/test/Twig/Tests/Fixtures/tags/macro/basic.test new file mode 100644 index 0000000..a1460ec --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/macro/basic.test @@ -0,0 +1,15 @@ +--TEST-- +"macro" tag +--TEMPLATE-- +{{ self.input('username') }} +{{ self.input('password', null, 'password', 1) }} + +{% macro input(name, value, type, size) %} + +{% endmacro %} +--DATA-- +return array() +--EXPECT-- + + + diff --git a/test/Twig/Tests/Fixtures/tags/macro/external.test b/test/Twig/Tests/Fixtures/tags/macro/external.test new file mode 100644 index 0000000..5cd3dae --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/macro/external.test @@ -0,0 +1,17 @@ +--TEST-- +"macro" tag +--TEMPLATE-- +{% import 'forms.twig' as forms %} + +{{ forms.input('username') }} +{{ forms.input('password', null, 'password', 1) }} +--TEMPLATE(forms.twig)-- +{% macro input(name, value, type, size) %} + +{% endmacro %} +--DATA-- +return array() +--EXPECT-- + + + diff --git a/test/Twig/Tests/Fixtures/tags/macro/self_import.test b/test/Twig/Tests/Fixtures/tags/macro/self_import.test new file mode 100644 index 0000000..ae55df8 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/macro/self_import.test @@ -0,0 +1,17 @@ +--TEST-- +"macro" tag +--TEMPLATE-- +{% import self as forms %} + +{{ forms.input('username') }} +{{ forms.input('password', null, 'password', 1) }} + +{% macro input(name, value, type, size) %} + +{% endmacro %} +--DATA-- +return array() +--EXPECT-- + + + diff --git a/test/Twig/Tests/Fixtures/tags/set/basic.test b/test/Twig/Tests/Fixtures/tags/set/basic.test new file mode 100644 index 0000000..75ad6d3 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/set/basic.test @@ -0,0 +1,17 @@ +--TEST-- +"set" tag +--TEMPLATE-- +{% set foo = 'foo' %} + +{{ foo }} + +{% set foo, bar = 'foo', 'bar' %} + +{{ foo }}{{ bar }} +--DATA-- +return array() +--EXPECT-- +foo + + +foobar diff --git a/test/Twig/Tests/Fixtures/tags/set/capture.test b/test/Twig/Tests/Fixtures/tags/set/capture.test new file mode 100644 index 0000000..4408ca8 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/set/capture.test @@ -0,0 +1,10 @@ +--TEST-- +"set" tag block capture +--TEMPLATE-- +{% set foo %}foo{% endset %} + +{{ foo }} +--DATA-- +return array() +--EXPECT-- +foo diff --git a/test/Twig/Tests/Fixtures/tags/set/expression.test b/test/Twig/Tests/Fixtures/tags/set/expression.test new file mode 100644 index 0000000..8ff434a --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/set/expression.test @@ -0,0 +1,12 @@ +--TEST-- +"set" tag +--TEMPLATE-- +{% set foo, bar = 'foo' ~ 'bar', 'bar' ~ 'foo' %} + +{{ foo }} +{{ bar }} +--DATA-- +return array() +--EXPECT-- +foobar +barfoo diff --git a/test/Twig/Tests/integrationTest.php b/test/Twig/Tests/integrationTest.php index 0c9c07b..f7a8760 100644 --- a/test/Twig/Tests/integrationTest.php +++ b/test/Twig/Tests/integrationTest.php @@ -13,7 +13,7 @@ class Twig_Tests_IntegrationTest extends PHPUnit_Framework_TestCase { public function getTests() { - $fixturesDir = realpath(dirname(__FILE__).'/../../fixtures/'); + $fixturesDir = realpath(dirname(__FILE__).'/Fixtures/'); $tests = array(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { diff --git a/test/fixtures/expressions/array.test b/test/fixtures/expressions/array.test deleted file mode 100644 index 32f9fe2..0000000 --- a/test/fixtures/expressions/array.test +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -Twig supports array notation ---TEMPLATE-- -{# empty array #} -{{ []|join(',') }} - -{{ [1, 2]|join(',') }} -{{ ['foo', "bar"]|join(',') }} -{{ [1, 'foo': 'bar']|join(',') }} -{{ [1, 'foo': 'bar']|keys|join(',') }} - -{# nested arrays #} -{% set a = [1, 2, [1, 2], 'foo': ['foo': 'bar']] %} -{{ a[2]|join(',') }} -{{ a["foo"]|join(',') }} - -{# works even if [] is used inside the array #} -{{ [foo[bar]]|join(',') }} - -{# elements can be any expression #} -{{ ['foo'|upper, bar|upper, bar == foo]|join(',') }} - -{# arrays can have a trailing , like in PHP #} -{{ - [ - 1, - 2, - ]|join(',') -}} ---DATA-- -return array('bar' => 'bar', 'foo' => array('bar' => 'bar')) ---EXPECT-- -1,2 -foo,bar -1,bar -0,foo - - -1,2 -bar - - -bar - - -FOO,BAR, - - -1,2 diff --git a/test/fixtures/expressions/array_call.test b/test/fixtures/expressions/array_call.test deleted file mode 100644 index f3df328..0000000 --- a/test/fixtures/expressions/array_call.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Twig supports method calls ---TEMPLATE-- -{{ items.foo }} -{{ items['foo'] }} -{{ items[foo] }} -{{ items[items[foo]] }} ---DATA-- -return array('foo' => 'bar', 'items' => array('foo' => 'bar', 'bar' => 'foo')) ---EXPECT-- -bar -bar -foo -bar diff --git a/test/fixtures/expressions/binary.test b/test/fixtures/expressions/binary.test deleted file mode 100644 index 009c8c8..0000000 --- a/test/fixtures/expressions/binary.test +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -Twig supports binary operations (+, -, *, /, ~, %, and, or) ---TEMPLATE-- -{{ 1 + 1 }} -{{ 2 - 1 }} -{{ 2 * 2 }} -{{ 2 / 2 }} -{{ 3 % 2 }} -{{ 1 and 1 }} -{{ 1 and 0 }} -{{ 0 and 1 }} -{{ 0 and 0 }} -{{ 1 or 1 }} -{{ 1 or 0 }} -{{ 0 or 1 }} -{{ 0 or 0 }} -{{ "foo" ~ "bar" }} -{{ foo ~ "bar" }} -{{ "foo" ~ bar }} -{{ foo ~ bar }} -{{ 20 // 7 }} ---DATA-- -return array('foo' => 'bar', 'bar' => 'foo') ---EXPECT-- -2 -1 -4 -1 -1 -1 - - - -1 -1 -1 - -foobar -barbar -foofoo -barfoo -2 diff --git a/test/fixtures/expressions/comparison.test b/test/fixtures/expressions/comparison.test deleted file mode 100644 index 4ed77e5..0000000 --- a/test/fixtures/expressions/comparison.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Twig supports comparison operators (==, !=, <, >, >=, <=) ---TEMPLATE-- -{{ 1 > 2 }}/{{ 1 > 1 }}/{{ 1 >= 2 }}/{{ 1 >= 1 }} -{{ 1 < 2 }}/{{ 1 < 1 }}/{{ 1 <= 2 }}/{{ 1 <= 1 }} -{{ 1 == 1 }}/{{ 1 == 2 }} -{{ 1 != 1 }}/{{ 1 != 2 }} -{{ 1 < 2 < 3 }}/{{ 1 < 2 < 3 < 4 }} ---DATA-- -return array() ---EXPECT-- -///1 -1//1/1 -1/ -/1 -1/1 diff --git a/test/fixtures/expressions/dotdot.test b/test/fixtures/expressions/dotdot.test deleted file mode 100644 index b3ee396..0000000 --- a/test/fixtures/expressions/dotdot.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Twig supports the .. operator ---TEMPLATE-- -{% for i in 0..10 %}{{ i }} {% endfor %} - -{% for letter in 'a'..'z' %}{{ letter }} {% endfor %} - -{% for letter in 'a'|upper..'z'|upper %}{{ letter }} {% endfor %} - -{% for i in foo[0]..foo[1] %}{{ i }} {% endfor %} ---DATA-- -return array('foo' => array(1, 10)) ---EXPECT-- -0 1 2 3 4 5 6 7 8 9 10 -a b c d e f g h i j k l m n o p q r s t u v w x y z -A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -1 2 3 4 5 6 7 8 9 10 diff --git a/test/fixtures/expressions/grouping.test b/test/fixtures/expressions/grouping.test deleted file mode 100644 index 79f8e0b..0000000 --- a/test/fixtures/expressions/grouping.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Twig supports grouping of expressions ---TEMPLATE-- -{{ (2 + 2) / 2 }} ---DATA-- -return array() ---EXPECT-- -2 diff --git a/test/fixtures/expressions/in.test b/test/fixtures/expressions/in.test deleted file mode 100644 index 344a97e..0000000 --- a/test/fixtures/expressions/in.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Twig supports the in operator ---TEMPLATE-- -{% if bar in foo %} -TRUE -{% endif %} -{% if not bar in foo %} -{% else %} -TRUE -{% endif %} ---DATA-- -return array('bar' => 'bar', 'foo' => array('bar' => 'bar')) ---EXPECT-- -TRUE -TRUE diff --git a/test/fixtures/expressions/magic_call.test b/test/fixtures/expressions/magic_call.test deleted file mode 100644 index 159db96..0000000 --- a/test/fixtures/expressions/magic_call.test +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Twig supports __call() for attributes ---TEMPLATE-- -{{ foo.foo }} -{{ foo.bar }} ---DATA-- -class TestClassForMagicCallAttributes -{ - public function getBar() - { - return 'bar_from_getbar'; - } - - public function __call($method, $arguments) - { - if ('foo' === $method) - { - return 'foo_from_call'; - } - - return false; - } -} -return array('foo' => new TestClassForMagicCallAttributes()) ---EXPECT-- -foo_from_call -bar_from_getbar diff --git a/test/fixtures/expressions/method_call.test b/test/fixtures/expressions/method_call.test deleted file mode 100644 index 14674b8..0000000 --- a/test/fixtures/expressions/method_call.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Twig supports method calls ---TEMPLATE-- -{{ items.foo.foo }} -{{ items.foo.getFoo() }} -{{ items.foo.bar }} -{{ items.foo['bar'] }} -{{ items.foo.bar('a', 43) }} -{{ items.foo.bar(foo) }} -{{ items.foo.self.foo() }} ---DATA-- -return array('foo' => 'bar', 'items' => array('foo' => new Foo(), 'bar' => 'foo')) ---EXPECT-- -foo -foo -bar - -bar_a-43 -bar_bar -foo diff --git a/test/fixtures/expressions/ternary_operator.test b/test/fixtures/expressions/ternary_operator.test deleted file mode 100644 index cbf555c..0000000 --- a/test/fixtures/expressions/ternary_operator.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Twig supports the ternary operator ---TEMPLATE-- -{{ 1 ? 'YES' : 'NO' }} -{{ 0 ? 'YES' : 'NO' }} -{{ 0 ? 'YES' : (1 ? 'YES1' : 'NO1') }} -{{ 0 ? 'YES' : (0 ? 'YES1' : 'NO1') }} ---DATA-- -return array() ---EXPECT-- -YES -NO -YES1 -NO1 diff --git a/test/fixtures/expressions/unary.test b/test/fixtures/expressions/unary.test deleted file mode 100644 index 2e1cb35..0000000 --- a/test/fixtures/expressions/unary.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Twig supports unary operators (not, -, +) ---TEMPLATE-- -{{ not 1 }}/{{ not 0 }} -{{ +1 + 1 }}/{{ -1 - 1 }} ---DATA-- -return array() ---EXPECT-- -/1 -2/-2 diff --git a/test/fixtures/filters/cycle.test b/test/fixtures/filters/cycle.test deleted file mode 100644 index d136833..0000000 --- a/test/fixtures/filters/cycle.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"cycle" filter ---TEMPLATE-- -{% for i in 0..6 %} -{{ array1|cycle(i) }}-{{ array2|cycle(i) }} -{% endfor %} ---DATA-- -return array('array1' => array('odd', 'even'), 'array2' => array('apple', 'orange', 'citrus')) ---EXPECT-- -odd-apple -even-orange -odd-citrus -even-apple -odd-orange -even-citrus -odd-apple diff --git a/test/fixtures/filters/date.test b/test/fixtures/filters/date.test deleted file mode 100644 index 21b57ba..0000000 --- a/test/fixtures/filters/date.test +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -"date" filter ---TEMPLATE-- -{{ date1|date }} -{{ date1|date('d/m/Y') }} -{{ date2|date }} -{{ date2|date('d/m/Y') }} -{{ date3|date }} -{{ date3|date('d/m/Y') }} -{{ date4|date }} -{{ date4|date('d/m/Y') }} ---DATA-- -date_default_timezone_set('UTC'); -return array('date1' => mktime(13, 45, 0, 10, 4, 2010), 'date2' => new DateTime('2010-10-04 13:45'), 'date3' => '2010-10-04 13:45', 'date4' => 1286199900) ---EXPECT-- -October 4, 2010 13:45 -04/10/2010 -October 4, 2010 13:45 -04/10/2010 -October 4, 2010 13:45 -04/10/2010 -October 4, 2010 13:45 -04/10/2010 diff --git a/test/fixtures/filters/default.test b/test/fixtures/filters/default.test deleted file mode 100644 index 8fd8017..0000000 --- a/test/fixtures/filters/default.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"default" filter ---TEMPLATE-- -{{ foo|default('bar') }} -{{ bar|default('foo') }} ---DATA-- -return array('foo' => null, 'bar' => 'bar') ---EXPECT-- -bar -bar diff --git a/test/fixtures/filters/even.test b/test/fixtures/filters/even.test deleted file mode 100644 index 835bb79..0000000 --- a/test/fixtures/filters/even.test +++ /dev/null @@ -1,9 +0,0 @@ ---TEST-- -"even" filter ---TEMPLATE-- -{{ 1|even }} -{{ 2|even }} ---DATA-- -return array() ---EXPECT-- -1 diff --git a/test/fixtures/filters/format.test b/test/fixtures/filters/format.test deleted file mode 100644 index 97221ff..0000000 --- a/test/fixtures/filters/format.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"format" filter ---TEMPLATE-- -{{ string|format(foo, 3) }} ---DATA-- -return array('string' => '%s/%d', 'foo' => 'bar') ---EXPECT-- -bar/3 diff --git a/test/fixtures/filters/in.test b/test/fixtures/filters/in.test deleted file mode 100644 index 4d6e337..0000000 --- a/test/fixtures/filters/in.test +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -"in" filter ---TEMPLATE-- -{{ 1|in([1, 2, 3]) }} -{{ 5|in([1, 2, 3]) }} -{{ 'cd'|in('abcde') }} -{{ 'ad'|in('abcde') }} -{{ 'foo'|in(foo) }} -{{ 'a'|in(foo|keys) }} ---DATA-- -class ItemsIteratorForInFilter implements Iterator -{ - protected $values = array('a' => 'foo', 'b' => 'bar'); - public function current() { return current($this->values); } - public function key() { return key($this->values); } - public function next() { return next($this->values); } - public function rewind() { return reset($this->values); } - public function valid() { return false !== current($this->values); } -} -return array('foo' => new ItemsIteratorForInFilter()) ---EXPECT-- -1 - -1 - -1 -1 diff --git a/test/fixtures/filters/length.test b/test/fixtures/filters/length.test deleted file mode 100644 index b5ef879..0000000 --- a/test/fixtures/filters/length.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"length" filter ---TEMPLATE-- -{{ array|length }} -{{ string|length }} ---DATA-- -return array('array' => array(1, 4), 'string' => 'foo') ---EXPECT-- -2 -3 diff --git a/test/fixtures/filters/odd.test b/test/fixtures/filters/odd.test deleted file mode 100644 index 1de0351..0000000 --- a/test/fixtures/filters/odd.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"odd" filter ---TEMPLATE-- -{{ 1|odd }} -{{ 2|odd }} ---DATA-- -return array() ---EXPECT-- - -1 diff --git a/test/fixtures/filters/sort.test b/test/fixtures/filters/sort.test deleted file mode 100644 index 21d575f..0000000 --- a/test/fixtures/filters/sort.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"sort" filter ---TEMPLATE-- -{{ array1|sort|join }} -{{ array2|sort|join }} ---DATA-- -return array('array1' => array(4, 1), 'array2' => array('foo', 'bar')) ---EXPECT-- -14 -barfoo diff --git a/test/fixtures/tags/autoescape/basic.test b/test/fixtures/tags/autoescape/basic.test deleted file mode 100644 index 6f6c1b9..0000000 --- a/test/fixtures/tags/autoescape/basic.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping on its children ---TEMPLATE-- -{% autoescape on %} -{{ var }}
-{% endautoescape %} -{% autoescape off %} -{{ var }}
-{% endautoescape %} -{% autoescape on %} -{{ var }}
-{% endautoescape %} -{% autoescape off %} -{{ var }}
-{% endautoescape %} ---DATA-- -return array('var' => '
') ---EXPECT-- -<br />
-

-<br />
-

diff --git a/test/fixtures/tags/autoescape/blocks.test b/test/fixtures/tags/autoescape/blocks.test deleted file mode 100644 index 8e05761..0000000 --- a/test/fixtures/tags/autoescape/blocks.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping on embedded blocks ---TEMPLATE-- -{% autoescape on %} - {% block foo %} - {{ var }} - {% endblock %} -{% endautoescape %} ---DATA-- -return array('var' => '
') ---EXPECT-- -<br /> diff --git a/test/fixtures/tags/autoescape/double_escaping.test b/test/fixtures/tags/autoescape/double_escaping.test deleted file mode 100644 index fc7aa8c..0000000 --- a/test/fixtures/tags/autoescape/double_escaping.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"autoescape" tag does not double-escape ---TEMPLATE-- -{% autoescape on %} -{{ var|escape }} -{% endautoescape %} ---DATA-- -return array('var' => '
') ---EXPECT-- -<br /> diff --git a/test/fixtures/tags/autoescape/literal.test b/test/fixtures/tags/autoescape/literal.test deleted file mode 100644 index 4c25706..0000000 --- a/test/fixtures/tags/autoescape/literal.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"autoescape" tag does not apply escaping on literals ---TEMPLATE-- -{% autoescape on %} -{{ "
" }} -{% endautoescape %} ---DATA-- -return array() ---EXPECT-- -
diff --git a/test/fixtures/tags/autoescape/nested.test b/test/fixtures/tags/autoescape/nested.test deleted file mode 100644 index 49f4da9..0000000 --- a/test/fixtures/tags/autoescape/nested.test +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -"autoescape" tags can be nested at will ---TEMPLATE-- -{{ var }} -{% autoescape on %} - {{ var }} - {% autoescape off %} - {{ var }} - {% autoescape on %} - {{ var }} - {% endautoescape %} - {{ var }} - {% endautoescape %} - {{ var }} -{% endautoescape %} -{{ var }} ---DATA-- -return array('var' => '
') ---EXPECT-- -<br /> - <br /> -
- <br /> -
- <br /> -<br /> diff --git a/test/fixtures/tags/autoescape/objects.test b/test/fixtures/tags/autoescape/objects.test deleted file mode 100644 index 44f41e1..0000000 --- a/test/fixtures/tags/autoescape/objects.test +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping to object method calls ---TEMPLATE-- -{% autoescape on %} -{{ user.name }} -{{ user.name|lower }} -{% endautoescape %} ---DATA-- -class UserForAutoEscapeTest -{ - public function getName() - { - return 'Fabien
'; - } -} -return array('user' => new UserForAutoEscapeTest()) ---EXPECT-- -Fabien<br /> -fabien<br /> diff --git a/test/fixtures/tags/autoescape/safe.test b/test/fixtures/tags/autoescape/safe.test deleted file mode 100644 index 9c45c0e..0000000 --- a/test/fixtures/tags/autoescape/safe.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"autoescape" tag does not escape when safe is used as a filter ---TEMPLATE-- -{% autoescape on %} -{{ var|safe }} -{% endautoescape %} ---DATA-- -return array('var' => '
') ---EXPECT-- -
diff --git a/test/fixtures/tags/autoescape/strategy.test b/test/fixtures/tags/autoescape/strategy.test deleted file mode 100644 index f3e09dd..0000000 --- a/test/fixtures/tags/autoescape/strategy.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"autoescape" tag accepts an escaping strategy ---TEMPLATE-- -{% autoescape on js %}{{ var }}{% endautoescape %} - -{% autoescape on html %}{{ var }}{% endautoescape %} ---DATA-- -return array('var' => '
"') ---EXPECT-- -
\" -<br />" diff --git a/test/fixtures/tags/autoescape/with_filters.test b/test/fixtures/tags/autoescape/with_filters.test deleted file mode 100644 index 3bb0dd4..0000000 --- a/test/fixtures/tags/autoescape/with_filters.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping before calling filters ---TEMPLATE-- -{% autoescape on %} -{{ var|nl2br }} -{{ var|nl2br|escape }} -{% endautoescape %} ---DATA-- -return array('var' => "\nTwig") ---EXPECT-- -<Fabien>
-Twig -<Fabien><br /> -Twig diff --git a/test/fixtures/tags/autoescape/with_filters_arguments.test b/test/fixtures/tags/autoescape/with_filters_arguments.test deleted file mode 100644 index 54cbe99..0000000 --- a/test/fixtures/tags/autoescape/with_filters_arguments.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping on filter arguments, but not on literals ---TEMPLATE-- -{% autoescape on %} -{{ var|nl2br("
") }} -{{ var|nl2br("
"|escape) }} -{{ var|nl2br(sep) }} -{{ var|nl2br(sep|safe) }} -{% endautoescape %} ---DATA-- -return array('var' => "\nTwig", 'sep' => '
') ---EXPECT-- -<Fabien>
-Twig -<Fabien><br /> -Twig -<Fabien><br /> -Twig -<Fabien>
-Twig diff --git a/test/fixtures/tags/block/basic.test b/test/fixtures/tags/block/basic.test deleted file mode 100644 index 360dcf0..0000000 --- a/test/fixtures/tags/block/basic.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"block" tag ---TEMPLATE-- -{% block title1 %}FOO{% endblock %} -{% block title2 foo|lower %} ---TEMPLATE(foo.twig)-- -{% block content %}{% endblock %} ---DATA-- -return array('foo' => 'bar') ---EXPECT-- -FOObar diff --git a/test/fixtures/tags/filter/basic.test b/test/fixtures/tags/filter/basic.test deleted file mode 100644 index 82094f2..0000000 --- a/test/fixtures/tags/filter/basic.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"filter" tag applies a filter on its children ---TEMPLATE-- -{% filter upper %} -Some text with a {{ var }} -{% endfilter %} ---DATA-- -return array('var' => 'var') ---EXPECT-- -SOME TEXT WITH A VAR diff --git a/test/fixtures/tags/filter/multiple.test b/test/fixtures/tags/filter/multiple.test deleted file mode 100644 index 75512ef..0000000 --- a/test/fixtures/tags/filter/multiple.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"filter" tags accept multiple chained filters ---TEMPLATE-- -{% filter lower|title %} - {{ var }} -{% endfilter %} ---DATA-- -return array('var' => 'VAR') ---EXPECT-- - Var diff --git a/test/fixtures/tags/filter/nested.test b/test/fixtures/tags/filter/nested.test deleted file mode 100644 index 7e4e4eb..0000000 --- a/test/fixtures/tags/filter/nested.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"filter" tags can be nested at will ---TEMPLATE-- -{% filter lower|title %} - {{ var }} - {% filter upper %} - {{ var }} - {% endfilter %} - {{ var }} -{% endfilter %} ---DATA-- -return array('var' => 'var') ---EXPECT-- - Var - Var - Var diff --git a/test/fixtures/tags/filter/with_for_tag.test b/test/fixtures/tags/filter/with_for_tag.test deleted file mode 100644 index 22745ea..0000000 --- a/test/fixtures/tags/filter/with_for_tag.test +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -"filter" tag applies the filter on "for" tags ---TEMPLATE-- -{% filter upper %} -{% for item in items %} -{{ item }} -{% endfor %} -{% endfilter %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- -A -B diff --git a/test/fixtures/tags/filter/with_if_tag.test b/test/fixtures/tags/filter/with_if_tag.test deleted file mode 100644 index 02381dd..0000000 --- a/test/fixtures/tags/filter/with_if_tag.test +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -"filter" tag applies the filter on "if" tags ---TEMPLATE-- -{% filter upper %} -{% if items %} -{{ items|join(', ') }} -{% endif %} - -{% if items.3 %} -FOO -{% else %} -{{ items.1 }} -{% endif %} - -{% if items.3 %} -FOO -{% elseif items.1 %} -{{ items.0 }} -{% endif %} - -{% endfilter %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- -A, B - -B - -A diff --git a/test/fixtures/tags/for/context.test b/test/fixtures/tags/for/context.test deleted file mode 100644 index ddc6930..0000000 --- a/test/fixtures/tags/for/context.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"for" tag keeps the context safe ---TEMPLATE-- -{% for item in items %} - {% for item in items %} - * {{ item }} - {% endfor %} - * {{ item }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * a - * b - * a - * a - * b - * b diff --git a/test/fixtures/tags/for/else.test b/test/fixtures/tags/for/else.test deleted file mode 100644 index 8c6a7d2..0000000 --- a/test/fixtures/tags/for/else.test +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -"for" tag can use an "else" clause ---TEMPLATE-- -{% for item in items %} - * {{ item }} -{% else %} - no item -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * a - * b ---DATA-- -return array('items' => array()) ---EXPECT-- - no item ---DATA-- -return array() ---EXPECT-- - no item diff --git a/test/fixtures/tags/for/inner_variables.test b/test/fixtures/tags/for/inner_variables.test deleted file mode 100644 index 49fb9ca..0000000 --- a/test/fixtures/tags/for/inner_variables.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"for" tag does not reset inner variables ---TEMPLATE-- -{% for i in 1..2 %} - {% for j in 0..2 %} - {{k}}{% set k = k+1 %} {{ loop.parent.loop.index }} - {% endfor %} -{% endfor %} ---DATA-- -return array('k' => 0) ---EXPECT-- - 0 1 - 1 1 - 2 1 - 3 2 - 4 2 - 5 2 diff --git a/test/fixtures/tags/for/keys.test b/test/fixtures/tags/for/keys.test deleted file mode 100644 index 4e22cb4..0000000 --- a/test/fixtures/tags/for/keys.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"for" tag can iterate over keys ---TEMPLATE-- -{% for key in items|keys %} - * {{ key }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * 0 - * 1 diff --git a/test/fixtures/tags/for/keys_and_values.test b/test/fixtures/tags/for/keys_and_values.test deleted file mode 100644 index 4c21168..0000000 --- a/test/fixtures/tags/for/keys_and_values.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"for" tag can iterate over keys and values ---TEMPLATE-- -{% for key, item in items %} - * {{ key }}/{{ item }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * 0/a - * 1/b diff --git a/test/fixtures/tags/for/loop_context.test b/test/fixtures/tags/for/loop_context.test deleted file mode 100644 index 93bc76a..0000000 --- a/test/fixtures/tags/for/loop_context.test +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -"for" tag adds a loop variable to the context ---TEMPLATE-- -{% for item in items %} - * {{ loop.index }}/{{ loop.index0 }} - * {{ loop.revindex }}/{{ loop.revindex0 }} - * {{ loop.first }}/{{ loop.last }}/{{ loop.length }} - -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * 1/0 - * 2/1 - * 1//2 - - * 2/1 - * 1/0 - * /1/2 diff --git a/test/fixtures/tags/for/loop_context_local.test b/test/fixtures/tags/for/loop_context_local.test deleted file mode 100644 index 4ec5440..0000000 --- a/test/fixtures/tags/for/loop_context_local.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"for" tag adds a loop variable to the context locally ---TEMPLATE-- -{% for item in items %} -{% endfor %} -{% if not loop %}WORKS{% endif %} ---DATA-- -return array('items' => array()) ---EXPECT-- -WORKS diff --git a/test/fixtures/tags/for/nested_else.test b/test/fixtures/tags/for/nested_else.test deleted file mode 100644 index f8b9f6b..0000000 --- a/test/fixtures/tags/for/nested_else.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"for" tag can use an "else" clause ---TEMPLATE-- -{% for item in items %} - {% for item in items1 %} - * {{ item }} - {% else %} - no {{ item }} - {% endfor %} -{% else %} - no item1 -{% endfor %} ---DATA-- -return array('items' => array('a', 'b'), 'items1' => array()) ---EXPECT-- -no a - no b diff --git a/test/fixtures/tags/for/objects.test b/test/fixtures/tags/for/objects.test deleted file mode 100644 index 5034437..0000000 --- a/test/fixtures/tags/for/objects.test +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -"for" tag iterates over iterable objects ---TEMPLATE-- -{% for item in items %} - * {{ item }} - * {{ loop.index }}/{{ loop.index0 }} - * {{ loop.first }} - -{% endfor %} - -{% for key, value in items %} - * {{ key }}/{{ value }} -{% endfor %} - -{% for key in items|keys %} - * {{ key }} -{% endfor %} ---DATA-- -class ItemsIterator implements Iterator -{ - protected $values = array('foo' => 'bar', 'bar' => 'foo'); - public function current() { return current($this->values); } - public function key() { return key($this->values); } - public function next() { return next($this->values); } - public function rewind() { return reset($this->values); } - public function valid() { return false !== current($this->values); } -} -return array('items' => new ItemsIterator()) ---EXPECT-- - * bar - * 1/0 - * 1 - - * foo - * 2/1 - * - - - * foo/bar - * bar/foo - - * foo - * bar diff --git a/test/fixtures/tags/for/objects_countable.test b/test/fixtures/tags/for/objects_countable.test deleted file mode 100644 index 4a1ff61..0000000 --- a/test/fixtures/tags/for/objects_countable.test +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -"for" tag iterates over iterable and countable objects ---TEMPLATE-- -{% for item in items %} - * {{ item }} - * {{ loop.index }}/{{ loop.index0 }} - * {{ loop.revindex }}/{{ loop.revindex0 }} - * {{ loop.first }}/{{ loop.last }}/{{ loop.length }} - -{% endfor %} - -{% for key, value in items %} - * {{ key }}/{{ value }} -{% endfor %} - -{% for key in items|keys %} - * {{ key }} -{% endfor %} ---DATA-- -class ItemsIteratorCountable implements Iterator, Countable -{ - protected $values = array('foo' => 'bar', 'bar' => 'foo'); - public function current() { return current($this->values); } - public function key() { return key($this->values); } - public function next() { return next($this->values); } - public function rewind() { return reset($this->values); } - public function valid() { return false !== current($this->values); } - public function count() { return count($this->values); } -} -return array('items' => new ItemsIteratorCountable()) ---EXPECT-- - * bar - * 1/0 - * 2/1 - * 1//2 - - * foo - * 2/1 - * 1/0 - * /1/2 - - - * foo/bar - * bar/foo - - * foo - * bar diff --git a/test/fixtures/tags/for/recursive.test b/test/fixtures/tags/for/recursive.test deleted file mode 100644 index 17b2e22..0000000 --- a/test/fixtures/tags/for/recursive.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"for" tags can be nested ---TEMPLATE-- -{% for key, item in items %} -* {{ key }} ({{ loop.length }}): -{% for value in item %} - * {{ value }} ({{ loop.length }}) -{% endfor %} -{% endfor %} ---DATA-- -return array('items' => array('a' => array('a1', 'a2', 'a3'), 'b' => array('b1'))) ---EXPECT-- -* a (2): - * a1 (3) - * a2 (3) - * a3 (3) -* b (2): - * b1 (1) diff --git a/test/fixtures/tags/for/values.test b/test/fixtures/tags/for/values.test deleted file mode 100644 index 82f2ae8..0000000 --- a/test/fixtures/tags/for/values.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"for" tag iterates over item values ---TEMPLATE-- -{% for item in items %} - * {{ item }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * a - * b diff --git a/test/fixtures/tags/if/basic.test b/test/fixtures/tags/if/basic.test deleted file mode 100644 index 2482ddf..0000000 --- a/test/fixtures/tags/if/basic.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"if" creates a condition ---TEMPLATE-- -{% if a %} - {{ a }} -{% elseif b %} - {{ b }} -{% else %} - NOTHING -{% endif %} ---DATA-- -return array('a' => 'a') ---EXPECT-- - a ---DATA-- -return array('b' => 'b') ---EXPECT-- - b ---DATA-- -return array() ---EXPECT-- - NOTHING diff --git a/test/fixtures/tags/if/expression.test b/test/fixtures/tags/if/expression.test deleted file mode 100644 index edfb73d..0000000 --- a/test/fixtures/tags/if/expression.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"if" takes an expression as a test ---TEMPLATE-- -{% if a < 2 %} - A1 -{% elseif a > 10 %} - A2 -{% else %} - A3 -{% endif %} ---DATA-- -return array('a' => 1) ---EXPECT-- - A1 ---DATA-- -return array('a' => 12) ---EXPECT-- - A2 ---DATA-- -return array('a' => 7) ---EXPECT-- - A3 diff --git a/test/fixtures/tags/include/basic.test b/test/fixtures/tags/include/basic.test deleted file mode 100644 index 8fe1a6c..0000000 --- a/test/fixtures/tags/include/basic.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" tag ---TEMPLATE-- -FOO -{% include "foo.twig" %} - -BAR ---TEMPLATE(foo.twig)-- -FOOBAR ---DATA-- -return array() ---EXPECT-- -FOO - -FOOBAR -BAR diff --git a/test/fixtures/tags/include/expression.test b/test/fixtures/tags/include/expression.test deleted file mode 100644 index eaeeb11..0000000 --- a/test/fixtures/tags/include/expression.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" tag allows expressions for the template to include ---TEMPLATE-- -FOO -{% include foo %} - -BAR ---TEMPLATE(foo.twig)-- -FOOBAR ---DATA-- -return array('foo' => 'foo.twig') ---EXPECT-- -FOO - -FOOBAR -BAR diff --git a/test/fixtures/tags/include/template_instance.test b/test/fixtures/tags/include/template_instance.test deleted file mode 100644 index 6ba064a..0000000 --- a/test/fixtures/tags/include/template_instance.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"include" tag accepts Twig_Template instance ---TEMPLATE-- -{% include foo %} FOO ---TEMPLATE(foo.twig)-- -BAR ---DATA-- -return array('foo' => $twig->loadTemplate('foo.twig')) ---EXPECT-- -BAR FOO diff --git a/test/fixtures/tags/include/with_variables.test b/test/fixtures/tags/include/with_variables.test deleted file mode 100644 index 96e393c..0000000 --- a/test/fixtures/tags/include/with_variables.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"include" tag accept variables ---TEMPLATE-- -{% include "foo.twig" with ['foo': 'bar'] %} -{% include "foo.twig" with vars %} ---TEMPLATE(foo.twig)-- -{{ foo }} ---DATA-- -return array('vars' => array('foo' => 'bar')) ---EXPECT-- -bar -bar diff --git a/test/fixtures/tags/inheritance/basic.test b/test/fixtures/tags/inheritance/basic.test deleted file mode 100644 index 0778a4b..0000000 --- a/test/fixtures/tags/inheritance/basic.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "foo.twig" %} - -{% block content %} -FOO -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}{% endblock %} ---DATA-- -return array() ---EXPECT-- -FOO diff --git a/test/fixtures/tags/inheritance/conditional.test b/test/fixtures/tags/inheritance/conditional.test deleted file mode 100644 index 3be8c47..0000000 --- a/test/fixtures/tags/inheritance/conditional.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends standalone ? foo : 'bar.twig' %} - -{% block content %}{% parent %}FOO{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}FOO{% endblock %} ---TEMPLATE(bar.twig)-- -{% block content %}BAR{% endblock %} ---DATA-- -return array('foo' => 'foo.twig', 'standalone' => true) ---EXPECT-- -FOOFOO diff --git a/test/fixtures/tags/inheritance/dynamic.test b/test/fixtures/tags/inheritance/dynamic.test deleted file mode 100644 index ee06ddc..0000000 --- a/test/fixtures/tags/inheritance/dynamic.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends foo %} - -{% block content %} -FOO -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}{% endblock %} ---DATA-- -return array('foo' => 'foo.twig') ---EXPECT-- -FOO diff --git a/test/fixtures/tags/inheritance/multiple.test b/test/fixtures/tags/inheritance/multiple.test deleted file mode 100644 index 4aba998..0000000 --- a/test/fixtures/tags/inheritance/multiple.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "layout.twig" %}{% block content %}{% parent %}index {% endblock %} ---TEMPLATE(layout.twig)-- -{% extends "base.twig" %}{% block content %}{% parent %}layout {% endblock %} ---TEMPLATE(base.twig)-- -{% block content %}base {% endblock %} ---DATA-- -return array() ---EXPECT-- -base layout index diff --git a/test/fixtures/tags/inheritance/parent.test b/test/fixtures/tags/inheritance/parent.test deleted file mode 100644 index b4a1daf..0000000 --- a/test/fixtures/tags/inheritance/parent.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "foo.twig" %} - -{% block content %}{% parent %}FOO{% parent %}{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}BAR{% endblock %} ---DATA-- -return array() ---EXPECT-- -BARFOOBAR diff --git a/test/fixtures/tags/inheritance/parent_nested.test b/test/fixtures/tags/inheritance/parent_nested.test deleted file mode 100644 index 1a5cf44..0000000 --- a/test/fixtures/tags/inheritance/parent_nested.test +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "foo.twig" %} - -{% block content %} - {% block inside %} - INSIDE OVERRIDDEN - {% endblock %} - - BEFORE - {% parent %} - AFTER -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %} - BAR -{% endblock %} ---DATA-- -return array() ---EXPECT-- - -INSIDE OVERRIDDEN - - BEFORE - BAR - AFTER diff --git a/test/fixtures/tags/inheritance/template_instance.test b/test/fixtures/tags/inheritance/template_instance.test deleted file mode 100644 index b2c48d9..0000000 --- a/test/fixtures/tags/inheritance/template_instance.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag accepts Twig_Template instance ---TEMPLATE-- -{% extends foo %} - -{% block content %} -{% parent %}FOO -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}BAR{% endblock %} ---DATA-- -return array('foo' => $twig->loadTemplate('foo.twig')) ---EXPECT-- -BARFOO diff --git a/test/fixtures/tags/macro/basic.test b/test/fixtures/tags/macro/basic.test deleted file mode 100644 index a1460ec..0000000 --- a/test/fixtures/tags/macro/basic.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{{ self.input('username') }} -{{ self.input('password', null, 'password', 1) }} - -{% macro input(name, value, type, size) %} - -{% endmacro %} ---DATA-- -return array() ---EXPECT-- - - - diff --git a/test/fixtures/tags/macro/external.test b/test/fixtures/tags/macro/external.test deleted file mode 100644 index 5cd3dae..0000000 --- a/test/fixtures/tags/macro/external.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{% import 'forms.twig' as forms %} - -{{ forms.input('username') }} -{{ forms.input('password', null, 'password', 1) }} ---TEMPLATE(forms.twig)-- -{% macro input(name, value, type, size) %} - -{% endmacro %} ---DATA-- -return array() ---EXPECT-- - - - diff --git a/test/fixtures/tags/macro/self_import.test b/test/fixtures/tags/macro/self_import.test deleted file mode 100644 index ae55df8..0000000 --- a/test/fixtures/tags/macro/self_import.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{% import self as forms %} - -{{ forms.input('username') }} -{{ forms.input('password', null, 'password', 1) }} - -{% macro input(name, value, type, size) %} - -{% endmacro %} ---DATA-- -return array() ---EXPECT-- - - - diff --git a/test/fixtures/tags/set/basic.test b/test/fixtures/tags/set/basic.test deleted file mode 100644 index 75ad6d3..0000000 --- a/test/fixtures/tags/set/basic.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"set" tag ---TEMPLATE-- -{% set foo = 'foo' %} - -{{ foo }} - -{% set foo, bar = 'foo', 'bar' %} - -{{ foo }}{{ bar }} ---DATA-- -return array() ---EXPECT-- -foo - - -foobar diff --git a/test/fixtures/tags/set/capture.test b/test/fixtures/tags/set/capture.test deleted file mode 100644 index 4408ca8..0000000 --- a/test/fixtures/tags/set/capture.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"set" tag block capture ---TEMPLATE-- -{% set foo %}foo{% endset %} - -{{ foo }} ---DATA-- -return array() ---EXPECT-- -foo diff --git a/test/fixtures/tags/set/expression.test b/test/fixtures/tags/set/expression.test deleted file mode 100644 index 8ff434a..0000000 --- a/test/fixtures/tags/set/expression.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"set" tag ---TEMPLATE-- -{% set foo, bar = 'foo' ~ 'bar', 'bar' ~ 'foo' %} - -{{ foo }} -{{ bar }} ---DATA-- -return array() ---EXPECT-- -foobar -barfoo -- 1.7.2.5