Added context and section unit tests for dot notation pragma.
This commit is contained in:
@@ -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}}'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user