From d026315a2c1ff29d2fda1fbd9776635da2adcdbe Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 24 Nov 2010 04:10:37 -0500 Subject: [PATCH] Even more ludicrous recursive section / implicit iterator tests. --- test/MustachePragmaImplicitIteratorTest.php | 33 +++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/test/MustachePragmaImplicitIteratorTest.php b/test/MustachePragmaImplicitIteratorTest.php index d582325..9a88359 100644 --- a/test/MustachePragmaImplicitIteratorTest.php +++ b/test/MustachePragmaImplicitIteratorTest.php @@ -50,11 +50,34 @@ class MustachePragmaImplicitIteratorTest extends PHPUnit_Framework_TestCase { $this->assertEquals('foobarbaz', $m->render('{{%IMPLICIT-ITERATOR iterator=i}}{{%DOT-NOTATION}}{{#items}}{{i.name}}{{/items}}')); } - public function testRecursiveSections() { - $m = new Mustache( - '{{%IMPLICIT-ITERATOR}}{{#items}}{{#.}}{{.}}{{/.}}{{/items}}', - array('items' => array(array('a', 'b', 'c'), array('d', 'e', 'f'))) + /** + * @dataProvider recursiveSectionData + */ + public function testRecursiveSections($template, $view, $result) { + $m = new Mustache(); + $this->assertEquals($result, $m->render($template, $view)); + } + + public function recursiveSectionData() { + return array( + array( + '{{%IMPLICIT-ITERATOR}}{{#items}}{{#.}}{{.}}{{/.}}{{/items}}', + array('items' => array(array('a', 'b', 'c'), array('d', 'e', 'f'))), + 'abcdef' + ), + array( + '{{%IMPLICIT-ITERATOR}}{{#items}}{{#.}}{{#.}}{{.}}{{/.}}{{/.}}{{/items}}', + array('items' => array(array(array('a', 'b'), array('c')), array(array('d'), array('e', 'f')))), + 'abcdef' + ), + array( + '{{%IMPLICIT-ITERATOR}}{{#items}}{{#.}}{{#items}}{{.}}{{/items}}{{/.}}{{/items}}', + array('items' => array( + array('items' => array('a', 'b', 'c')), + array('items' => array('d', 'e', 'f')), + )), + 'abcdef' + ), ); - $this->assertEquals('abcdef', $m->render()); } } \ No newline at end of file