Added context and section unit tests for dot notation pragma.

This commit is contained in:
Justin Hileman
2010-06-01 17:02:36 -04:00
parent 96c42105ec
commit 38a5e57514
2 changed files with 29 additions and 2 deletions
+27
View File
@@ -31,4 +31,31 @@ class MustachePragmaDotNotationTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($m->render('{{%DOT-NOTATION}}{{one.one}}|{{one.two}}|{{one.three}}'), 'one-one|one-two|one-three'); $this->assertEquals($m->render('{{%DOT-NOTATION}}{{one.one}}|{{one.two}}|{{one.three}}'), 'one-one|one-two|one-three');
} }
public function testDotNotationContext() {
$data = array('parent' => array('items' => array(
array('item' => array('index' => 1)),
array('item' => array('index' => 2)),
array('item' => array('index' => 3)),
array('item' => array('index' => 4)),
array('item' => array('index' => 5)),
)));
$m = new Mustache('', $data);
$this->assertEquals('12345', $m->render('{{%DOT-NOTATION}}{{#parent}}{{#items}}{{item.index}}{{/items}}{{/parent}}'));
}
public function testDotNotationSectionNames() {
$data = array('parent' => array('items' => array(
array('item' => array('index' => 1)),
array('item' => array('index' => 2)),
array('item' => array('index' => 3)),
array('item' => array('index' => 4)),
array('item' => array('index' => 5)),
)));
$m = new Mustache('', $data);
$this->assertEquals('.....', $m->render('{{%DOT-NOTATION}}{{#parent.items}}.{{/parent.items}}'));
$this->assertEquals('12345', $m->render('{{%DOT-NOTATION}}{{#parent.items}}{{item.index}}{{/parent.items}}'));
$this->assertEquals('12345', $m->render('{{%DOT-NOTATION}}{{#parent.items}}{{#item}}{{index}}{{/item}}{{/parent.items}}'));
}
} }
+2 -2
View File
@@ -176,11 +176,11 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
*/ */
public function testResetTemplateForMultipleInvocations() { public function testResetTemplateForMultipleInvocations() {
$m = new Mustache('Sirve.'); $m = new Mustache('Sirve.');
$m->render('No sirve.'); $this->assertEquals('No sirve.', $m->render('No sirve.'));
$this->assertEquals('Sirve.', $m->render()); $this->assertEquals('Sirve.', $m->render());
$m2 = new Mustache(); $m2 = new Mustache();
$m2->render('No sirve.'); $this->assertEquals('No sirve.', $m2->render('No sirve.'));
$this->assertEquals('', $m2->render()); $this->assertEquals('', $m2->render());
} }