From 5186d0bc18dede6ea0c7022046dc7842dc370f5d Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 5 Jul 2010 21:13:08 -0400 Subject: [PATCH] Test case for #3 (_varIsIterable issues). --- test/MustacheObjectSectionTest.php | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/MustacheObjectSectionTest.php diff --git a/test/MustacheObjectSectionTest.php b/test/MustacheObjectSectionTest.php new file mode 100644 index 0000000..58d4286 --- /dev/null +++ b/test/MustacheObjectSectionTest.php @@ -0,0 +1,56 @@ +assertEquals('Foo', $alpha->render('{{#foo}}{{name}}{{/foo}}')); + } + + public function testObjectWithGet() { + $beta = new Beta(); + $this->assertEquals('Foo', $beta->render('{{#foo}}{{name}}{{/foo}}')); + } + + public function testSectionObjectWithGet() { + $gamma = new Gamma(); + $this->assertEquals('Foo', $gamma->render('{{#bar}}{{#foo}}{{name}}{{/foo}}{{/bar}}')); + } +} + +class Alpha extends Mustache { + public $foo; + + public function __construct() { + $this->foo = new StdClass(); + $this->foo->name = 'Foo'; + $this->foo->number = 1; + } +} + +class Beta extends Mustache { + protected $_data = array(); + + public function __construct() { + $this->_data['foo'] = new StdClass(); + $this->_data['foo']->name = 'Foo'; + $this->_data['foo']->number = 1; + } + + public function __isset($name) { + return array_key_exists($name, $this->_data); + } + + public function __get($name) { + return $this->_data[$name]; + } +} + +class Gamma extends Mustache { + public $bar; + + public function __construct() { + $this->bar = new Beta(); + } +} \ No newline at end of file