|
|
@@ -35,6 +35,11 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|
|
|
|
|
const TEST_CLASS = 'Mustache';
|
|
|
|
|
|
+ protected $knownIssues = array(
|
|
|
+ 'Delimiters' => "Known issue: sections don't respect delimiter changes",
|
|
|
+ 'SectionsSpaces' => "Known issue: Mustache fails miserably at whitespace",
|
|
|
+ );
|
|
|
+
|
|
|
/**
|
|
|
* Test Mustache constructor.
|
|
|
*
|
|
|
@@ -136,6 +141,23 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|
|
$this->assertEquals('Zappa, Frank', $m->render('{{last_name}}, {{first_name}}', array('first_name' => 'Frank', 'last_name' => 'Zappa')));
|
|
|
}
|
|
|
|
|
|
+ public function testRenderWithPartials() {
|
|
|
+ $m = new Mustache('{{>stache}}', null, array('stache' => '{{first_name}} {{last_name}}'));
|
|
|
+ $this->assertEquals('Charlie Chaplin', $m->render(null, array('first_name' => 'Charlie', 'last_name' => 'Chaplin')));
|
|
|
+ $this->assertEquals('Zappa, Frank', $m->render('{{last_name}}, {{first_name}}', array('first_name' => 'Frank', 'last_name' => 'Zappa')));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Mustache should allow newlines (and other whitespace) in comments and all other tags.
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testNewlinesInComments() {
|
|
|
+ $m = new Mustache("{{! comment \n \t still a comment... }}");
|
|
|
+ $this->assertEquals('', $m->render());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Mustache should return the same thing when invoked multiple times.
|
|
|
*
|
|
|
@@ -166,10 +188,9 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|
|
$this->assertEquals($first, $second);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Mustache should not use templates passed to the render() method for subsequent invocations.
|
|
|
- *
|
|
|
+ *
|
|
|
* @access public
|
|
|
* @return void
|
|
|
*/
|
|
|
@@ -177,7 +198,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|
|
$m = new Mustache('Sirve.');
|
|
|
$this->assertEquals('No sirve.', $m->render('No sirve.'));
|
|
|
$this->assertEquals('Sirve.', $m->render());
|
|
|
-
|
|
|
+
|
|
|
$m2 = new Mustache();
|
|
|
$this->assertEquals('No sirve.', $m2->render('No sirve.'));
|
|
|
$this->assertEquals('', $m2->render());
|
|
|
@@ -186,14 +207,17 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|
|
/**
|
|
|
* testClone function.
|
|
|
*
|
|
|
+ * @group examples
|
|
|
* @dataProvider getExamples
|
|
|
* @access public
|
|
|
+ * @param string $class
|
|
|
+ * @param string $template
|
|
|
+ * @param string $output
|
|
|
* @return void
|
|
|
*/
|
|
|
public function test__clone($class, $template, $output) {
|
|
|
- if ($class == 'Delimiters') {
|
|
|
- $this->markTestSkipped("Known issue: sections don't respect delimiter changes");
|
|
|
- return;
|
|
|
+ if (isset($this->knownIssues[$class])) {
|
|
|
+ return $this->markTestSkipped($this->knownIssues[$class]);
|
|
|
}
|
|
|
|
|
|
$m = new $class;
|
|
|
@@ -214,17 +238,17 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|
|
/**
|
|
|
* Test everything in the `examples` directory.
|
|
|
*
|
|
|
+ * @group examples
|
|
|
* @dataProvider getExamples
|
|
|
* @access public
|
|
|
- * @param mixed $class
|
|
|
- * @param mixed $template
|
|
|
- * @param mixed $output
|
|
|
+ * @param string $class
|
|
|
+ * @param string $template
|
|
|
+ * @param string $output
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testExamples($class, $template, $output) {
|
|
|
- if ($class == 'Delimiters') {
|
|
|
- $this->markTestSkipped("Known issue: sections don't respect delimiter changes");
|
|
|
- return;
|
|
|
+ if (isset($this->knownIssues[$class])) {
|
|
|
+ return $this->markTestSkipped($this->knownIssues[$class]);
|
|
|
}
|
|
|
|
|
|
$m = new $class;
|