aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test')
-rw-r--r--vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test43
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test
new file mode 100644
index 00000000..50344379
--- /dev/null
+++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test
@@ -0,0 +1,43 @@
1--TEST--
2"for" tag iterates over iterable objects
3--TEMPLATE--
4{% for item in items %}
5 * {{ item }}
6 * {{ loop.index }}/{{ loop.index0 }}
7 * {{ loop.first }}
8
9{% endfor %}
10
11{% for key, value in items %}
12 * {{ key }}/{{ value }}
13{% endfor %}
14
15{% for key in items|keys %}
16 * {{ key }}
17{% endfor %}
18--DATA--
19class ItemsIterator implements Iterator
20{
21 protected $values = array('foo' => 'bar', 'bar' => 'foo');
22 public function current() { return current($this->values); }
23 public function key() { return key($this->values); }
24 public function next() { return next($this->values); }
25 public function rewind() { return reset($this->values); }
26 public function valid() { return false !== current($this->values); }
27}
28return array('items' => new ItemsIterator())
29--EXPECT--
30 * bar
31 * 1/0
32 * 1
33
34 * foo
35 * 2/1
36 *
37
38
39 * foo/bar
40 * bar/foo
41
42 * foo
43 * bar