From 2edd7330a0694ec67b3fa29cbf66e38fa12ec1c8 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 5 Jul 2010 15:27:43 -0400 Subject: [PATCH] Failing test for higher-order section side effects--issue #4 --- test/MustacheHigherOrderSectionsTest.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/MustacheHigherOrderSectionsTest.php b/test/MustacheHigherOrderSectionsTest.php index 63b8d3b..1d3ac35 100644 --- a/test/MustacheHigherOrderSectionsTest.php +++ b/test/MustacheHigherOrderSectionsTest.php @@ -83,6 +83,18 @@ class MustacheHigherOrderSectionsTest extends PHPUnit_Framework_TestCase { $this->foo->render('{{#wrap}}{{name}}{{/wrap}}', $data) ); } + + public function testMonsters() { + $frank = new Monster(); + $frank->title = 'Dr.'; + $frank->name = 'Frankenstein'; + $this->assertEquals('Dr. Frankenstein', $frank->render()); + + $dracula = new Monster(); + $dracula->title = 'Count'; + $dracula->name = 'Dracula'; + $this->assertEquals('Count Dracula', $dracula->render()); + } } class Foo extends Mustache { @@ -106,7 +118,7 @@ class Foo extends Mustache { public function wrapWithBoth($text) { return self::wrapWithStrong(self::wrapWithEm($text)); } - + public static function staticTrim($text) { return trim($text); } @@ -114,4 +126,10 @@ class Foo extends Mustache { function make_my_logo_bigger($text) { return sprintf('

%s

', $text); +} + +class Monster extends Mustache { + public $_template = '{{#title}}{{title}} {{/title}}{{name}}'; + public $title; + public $name; } \ No newline at end of file