Merge branch 'dev' into feature/section-stack
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class SectionsNested extends Mustache {
|
||||||
|
public $name = 'Little Mac';
|
||||||
|
|
||||||
|
public function enemies() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'name' => 'Von Kaiser',
|
||||||
|
'enemies' => array(
|
||||||
|
array('name' => 'Super Macho Man'),
|
||||||
|
array('name' => 'Piston Honda'),
|
||||||
|
array('name' => 'Mr. Sandman'),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Mike Tyson',
|
||||||
|
'enemies' => array(
|
||||||
|
array('name' => 'Soda Popinski'),
|
||||||
|
array('name' => 'King Hippo'),
|
||||||
|
array('name' => 'Great Tiger'),
|
||||||
|
array('name' => 'Glass Joe'),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Don Flamenco',
|
||||||
|
'enemies' => array(
|
||||||
|
array('name' => 'Bald Bull'),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Enemies of {{ name }}:
|
||||||
|
{{# enemies }}
|
||||||
|
{{ name }} ... who also has enemies:
|
||||||
|
{{# enemies }}
|
||||||
|
--> {{ name }}
|
||||||
|
{{/ enemies }}
|
||||||
|
{{/ enemies }}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
Enemies of Little Mac:
|
||||||
|
Von Kaiser ... who also has enemies:
|
||||||
|
--> Super Macho Man
|
||||||
|
--> Piston Honda
|
||||||
|
--> Mr. Sandman
|
||||||
|
Mike Tyson ... who also has enemies:
|
||||||
|
--> Soda Popinski
|
||||||
|
--> King Hippo
|
||||||
|
--> Great Tiger
|
||||||
|
--> Glass Joe
|
||||||
|
Don Flamenco ... who also has enemies:
|
||||||
|
--> Bald Bull
|
||||||
@@ -15,6 +15,7 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @group interpolation
|
||||||
* @expectedException MustacheException
|
* @expectedException MustacheException
|
||||||
*/
|
*/
|
||||||
public function testThrowsUnknownVariableException() {
|
public function testThrowsUnknownVariableException() {
|
||||||
@@ -22,6 +23,7 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @group sections
|
||||||
* @expectedException MustacheException
|
* @expectedException MustacheException
|
||||||
*/
|
*/
|
||||||
public function testThrowsUnclosedSectionException() {
|
public function testThrowsUnclosedSectionException() {
|
||||||
@@ -29,6 +31,15 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @group sections
|
||||||
|
* @expectedException MustacheException
|
||||||
|
*/
|
||||||
|
public function testThrowsUnclosedInvertedSectionException() {
|
||||||
|
$this->pickyMustache->render('{{^unclosed}}');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group sections
|
||||||
* @expectedException MustacheException
|
* @expectedException MustacheException
|
||||||
*/
|
*/
|
||||||
public function testThrowsUnexpectedCloseSectionException() {
|
public function testThrowsUnexpectedCloseSectionException() {
|
||||||
@@ -36,6 +47,7 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @group partials
|
||||||
* @expectedException MustacheException
|
* @expectedException MustacheException
|
||||||
*/
|
*/
|
||||||
public function testThrowsUnknownPartialException() {
|
public function testThrowsUnknownPartialException() {
|
||||||
@@ -43,25 +55,36 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @group pragmas
|
||||||
* @expectedException MustacheException
|
* @expectedException MustacheException
|
||||||
*/
|
*/
|
||||||
public function testThrowsUnknownPragmaException() {
|
public function testThrowsUnknownPragmaException() {
|
||||||
$this->pickyMustache->render('{{%SWEET-MUSTACHE-BRO}}');
|
$this->pickyMustache->render('{{%SWEET-MUSTACHE-BRO}}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group sections
|
||||||
|
*/
|
||||||
public function testDoesntThrowUnclosedSectionException() {
|
public function testDoesntThrowUnclosedSectionException() {
|
||||||
$this->assertEquals('', $this->slackerMustache->render('{{#unclosed}}'));
|
$this->assertEquals('', $this->slackerMustache->render('{{#unclosed}}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group sections
|
||||||
|
*/
|
||||||
public function testDoesntThrowUnexpectedCloseSectionException() {
|
public function testDoesntThrowUnexpectedCloseSectionException() {
|
||||||
$this->assertEquals('', $this->slackerMustache->render('{{/unopened}}'));
|
$this->assertEquals('', $this->slackerMustache->render('{{/unopened}}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group partials
|
||||||
|
*/
|
||||||
public function testDoesntThrowUnknownPartialException() {
|
public function testDoesntThrowUnknownPartialException() {
|
||||||
$this->assertEquals('', $this->slackerMustache->render('{{>impartial}}'));
|
$this->assertEquals('', $this->slackerMustache->render('{{>impartial}}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @group pragmas
|
||||||
* @expectedException MustacheException
|
* @expectedException MustacheException
|
||||||
*/
|
*/
|
||||||
public function testGetPragmaOptionsThrowsExceptionsIfItThinksYouHaveAPragmaButItTurnsOutYouDont() {
|
public function testGetPragmaOptionsThrowsExceptionsIfItThinksYouHaveAPragmaButItTurnsOutYouDont() {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
require_once '../Mustache.php';
|
require_once '../Mustache.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group sections
|
||||||
|
*/
|
||||||
class MustacheObjectSectionTest extends PHPUnit_Framework_TestCase {
|
class MustacheObjectSectionTest extends PHPUnit_Framework_TestCase {
|
||||||
public function testBasicObject() {
|
public function testBasicObject() {
|
||||||
$alpha = new Alpha();
|
$alpha = new Alpha();
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
require_once '../Mustache.php';
|
require_once '../Mustache.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group pragmas
|
||||||
|
*/
|
||||||
class MustachePragmaDotNotationTest extends PHPUnit_Framework_TestCase {
|
class MustachePragmaDotNotationTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testDotTraversal() {
|
public function testDotTraversal() {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
require_once '../Mustache.php';
|
require_once '../Mustache.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group pragmas
|
||||||
|
*/
|
||||||
class MustachePragmaImplicitIteratorTest extends PHPUnit_Framework_TestCase {
|
class MustachePragmaImplicitIteratorTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testEnablePragma() {
|
public function testEnablePragma() {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
require_once '../Mustache.php';
|
require_once '../Mustache.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group pragmas
|
||||||
|
*/
|
||||||
class MustachePragmaTest extends PHPUnit_Framework_TestCase {
|
class MustachePragmaTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testUnknownPragmaException() {
|
public function testUnknownPragmaException() {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
require_once '../Mustache.php';
|
require_once '../Mustache.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group pragmas
|
||||||
|
*/
|
||||||
class MustachePragmaUnescapedTest extends PHPUnit_Framework_TestCase {
|
class MustachePragmaUnescapedTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testPragmaUnescaped() {
|
public function testPragmaUnescaped() {
|
||||||
|
|||||||
+15
-18
@@ -132,8 +132,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
/**
|
/**
|
||||||
* Test render() with data.
|
* Test render() with data.
|
||||||
*
|
*
|
||||||
* @access public
|
* @group interpolation
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testRenderWithData() {
|
public function testRenderWithData() {
|
||||||
$m = new Mustache('{{first_name}} {{last_name}}');
|
$m = new Mustache('{{first_name}} {{last_name}}');
|
||||||
@@ -141,6 +140,9 @@ 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')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group partials
|
||||||
|
*/
|
||||||
public function testRenderWithPartials() {
|
public function testRenderWithPartials() {
|
||||||
$m = new Mustache('{{>stache}}', null, array('stache' => '{{first_name}} {{last_name}}'));
|
$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('Charlie Chaplin', $m->render(null, array('first_name' => 'Charlie', 'last_name' => 'Chaplin')));
|
||||||
@@ -150,8 +152,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
/**
|
/**
|
||||||
* Mustache should allow newlines (and other whitespace) in comments and all other tags.
|
* Mustache should allow newlines (and other whitespace) in comments and all other tags.
|
||||||
*
|
*
|
||||||
* @access public
|
* @group comments
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testNewlinesInComments() {
|
public function testNewlinesInComments() {
|
||||||
$m = new Mustache("{{! comment \n \t still a comment... }}");
|
$m = new Mustache("{{! comment \n \t still a comment... }}");
|
||||||
@@ -160,9 +161,6 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustache should return the same thing when invoked multiple times.
|
* Mustache should return the same thing when invoked multiple times.
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testMultipleInvocations() {
|
public function testMultipleInvocations() {
|
||||||
$m = new Mustache('x');
|
$m = new Mustache('x');
|
||||||
@@ -176,8 +174,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
/**
|
/**
|
||||||
* Mustache should return the same thing when invoked multiple times.
|
* Mustache should return the same thing when invoked multiple times.
|
||||||
*
|
*
|
||||||
* @access public
|
* @group interpolation
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testMultipleInvocationsWithTags() {
|
public function testMultipleInvocationsWithTags() {
|
||||||
$m = new Mustache('{{one}} {{two}}', array('one' => 'foo', 'two' => 'bar'));
|
$m = new Mustache('{{one}} {{two}}', array('one' => 'foo', 'two' => 'bar'));
|
||||||
@@ -190,9 +187,6 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustache should not use templates passed to the render() method for subsequent invocations.
|
* Mustache should not use templates passed to the render() method for subsequent invocations.
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testResetTemplateForMultipleInvocations() {
|
public function testResetTemplateForMultipleInvocations() {
|
||||||
$m = new Mustache('Sirve.');
|
$m = new Mustache('Sirve.');
|
||||||
@@ -205,15 +199,14 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testClone function.
|
* Test the __clone() magic function.
|
||||||
*
|
*
|
||||||
* @group examples
|
* @group examples
|
||||||
* @dataProvider getExamples
|
* @dataProvider getExamples
|
||||||
* @access public
|
*
|
||||||
* @param string $class
|
* @param string $class
|
||||||
* @param string $template
|
* @param string $template
|
||||||
* @param string $output
|
* @param string $output
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function test__clone($class, $template, $output) {
|
public function test__clone($class, $template, $output) {
|
||||||
if (isset($this->knownIssues[$class])) {
|
if (isset($this->knownIssues[$class])) {
|
||||||
@@ -240,11 +233,10 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
*
|
*
|
||||||
* @group examples
|
* @group examples
|
||||||
* @dataProvider getExamples
|
* @dataProvider getExamples
|
||||||
* @access public
|
*
|
||||||
* @param string $class
|
* @param string $class
|
||||||
* @param string $template
|
* @param string $template
|
||||||
* @param string $output
|
* @param string $output
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testExamples($class, $template, $output) {
|
public function testExamples($class, $template, $output) {
|
||||||
if (isset($this->knownIssues[$class])) {
|
if (isset($this->knownIssues[$class])) {
|
||||||
@@ -266,7 +258,6 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
* This whole mess will be refined later to be more intuitive and less prescriptive, but it'll
|
* This whole mess will be refined later to be more intuitive and less prescriptive, but it'll
|
||||||
* do for now. Especially since it means we can have unit tests :)
|
* do for now. Especially since it means we can have unit tests :)
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getExamples() {
|
public function getExamples() {
|
||||||
@@ -317,6 +308,9 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group delimiters
|
||||||
|
*/
|
||||||
public function testCrazyDelimiters() {
|
public function testCrazyDelimiters() {
|
||||||
$m = new Mustache(null, array('result' => 'success'));
|
$m = new Mustache(null, array('result' => 'success'));
|
||||||
$this->assertEquals('success', $m->render('{{=[[ ]]=}}[[ result ]]'));
|
$this->assertEquals('success', $m->render('{{=[[ ]]=}}[[ result ]]'));
|
||||||
@@ -327,6 +321,9 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals('success', $m->render('{{=// \\\\}}// result \\\\'));
|
$this->assertEquals('success', $m->render('{{=// \\\\}}// result \\\\'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group delimiters
|
||||||
|
*/
|
||||||
public function testResetDelimiters() {
|
public function testResetDelimiters() {
|
||||||
$m = new Mustache(null, array('result' => 'success'));
|
$m = new Mustache(null, array('result' => 'success'));
|
||||||
$this->assertEquals('success', $m->render('{{=[[ ]]=}}[[ result ]]'));
|
$this->assertEquals('success', $m->render('{{=[[ ]]=}}[[ result ]]'));
|
||||||
|
|||||||
Reference in New Issue
Block a user