Added __toString() test.

This commit is contained in:
Justin Hileman
2010-04-29 21:35:41 -04:00
parent a9ea1db322
commit 4d40070c69
+22 -9
View File
@@ -68,21 +68,19 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($output, $m4->render($template)); $this->assertEquals($output, $m4->render($template));
} }
/** /**
* Test everything in the `examples` directory. * Test __toString() function.
* *
* @dataProvider getExamples
* @access public * @access public
* @param mixed $class
* @param mixed $template
* @param mixed $output
* @return void * @return void
*/ */
public function testExamples($class, $template, $output) { public function test__toString() {
$m = new $class; $m = new Mustache('{{first_name}} {{last_name}}', array('first_name' => 'Karl', 'last_name' => 'Marx'));
$this->assertEquals($output, $m->render($template));
}
$this->assertEquals('Karl Marx', $m->__toString());
$this->assertEquals('Karl Marx', (string) $m);
}
/** /**
* Test render(). * 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'))); $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. * Data provider for testExamples method.
* *