From 4d40070c6900ade3e57c4200fcb8cb162b5ca192 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 29 Apr 2010 21:35:41 -0400 Subject: [PATCH] Added __toString() test. --- test/MustacheTest.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/test/MustacheTest.php b/test/MustacheTest.php index bf5c5c9..f43a49a 100644 --- a/test/MustacheTest.php +++ b/test/MustacheTest.php @@ -68,21 +68,19 @@ class MustacheTest extends PHPUnit_Framework_TestCase { $this->assertEquals($output, $m4->render($template)); } + /** - * Test everything in the `examples` directory. + * Test __toString() function. * - * @dataProvider getExamples * @access public - * @param mixed $class - * @param mixed $template - * @param mixed $output * @return void */ - public function testExamples($class, $template, $output) { - $m = new $class; - $this->assertEquals($output, $m->render($template)); - } + public function test__toString() { + $m = new Mustache('{{first_name}} {{last_name}}', array('first_name' => 'Karl', 'last_name' => 'Marx')); + $this->assertEquals('Karl Marx', $m->__toString()); + $this->assertEquals('Karl Marx', (string) $m); + } /** * Test render(). @@ -119,6 +117,21 @@ class MustacheTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Zappa, Frank', $m->render('{{last_name}}, {{first_name}}', array('first_name' => 'Frank', 'last_name' => 'Zappa'))); } + /** + * Test everything in the `examples` directory. + * + * @dataProvider getExamples + * @access public + * @param mixed $class + * @param mixed $template + * @param mixed $output + * @return void + */ + public function testExamples($class, $template, $output) { + $m = new $class; + $this->assertEquals($output, $m->render($template)); + } + /** * Data provider for testExamples method. *