Quellcode durchsuchen

Added __toString() test.

Justin Hileman vor 15 Jahren
Ursprung
Commit
4d40070c69
1 geänderte Dateien mit 22 neuen und 9 gelöschten Zeilen
  1. 22 9
      test/MustacheTest.php

+ 22 - 9
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.
 	 *