summaryrefslogtreecommitdiff
path: root/vendor/zordius/lightncandy/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/zordius/lightncandy/tests')
-rw-r--r--vendor/zordius/lightncandy/tests/LCRun3Test.php376
-rw-r--r--vendor/zordius/lightncandy/tests/LightnCandyTest.php460
-rw-r--r--vendor/zordius/lightncandy/tests/errorTest.php410
-rw-r--r--vendor/zordius/lightncandy/tests/example_debug.php28
-rw-r--r--vendor/zordius/lightncandy/tests/example_helpers.php58
-rw-r--r--vendor/zordius/lightncandy/tests/handlebarsSpecTest.php162
-rw-r--r--vendor/zordius/lightncandy/tests/helpers_for_test.php137
-rw-r--r--vendor/zordius/lightncandy/tests/mustacheSpecTest.php53
-rw-r--r--vendor/zordius/lightncandy/tests/recursive.tmpl1
-rw-r--r--vendor/zordius/lightncandy/tests/regressionTest.php736
-rw-r--r--vendor/zordius/lightncandy/tests/test1.tmpl1
-rw-r--r--vendor/zordius/lightncandy/tests/test2.tmpl1
-rw-r--r--vendor/zordius/lightncandy/tests/test3.tmpl1
13 files changed, 2424 insertions, 0 deletions
diff --git a/vendor/zordius/lightncandy/tests/LCRun3Test.php b/vendor/zordius/lightncandy/tests/LCRun3Test.php
new file mode 100644
index 00000000..63d6348e
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/LCRun3Test.php
@@ -0,0 +1,376 @@
+<?php
+/**
+ * Generated by build/gen_test
+ */
+require_once('src/lightncandy.php');
+
+class LCRun3Test extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @covers LCRun3::debug
+ */
+ public function testOn_debug() {
+ $method = new ReflectionMethod('LCRun3', 'debug');
+ $this->assertEquals('{{123}}', $method->invoke(null,
+ '123', 'miss', array('flags' => array('debug' => LCRun3::DEBUG_TAGS)), ''
+ ));
+ $this->assertEquals('<!--MISSED((-->{{#123}}<!--))--><!--SKIPPED--><!--MISSED((-->{{/123}}<!--))-->', $method->invoke(null,
+ '123', 'wi', array('flags' => array('debug' => LCRun3::DEBUG_TAGS_HTML)), false, false, function () {return 'A';}
+ ));
+ }
+ /**
+ * @covers LCRun3::v
+ */
+ public function testOn_v() {
+ $method = new ReflectionMethod('LCRun3', 'v');
+ $this->assertEquals(null, $method->invoke(null,
+ array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0, 'mustlok' => 0)), 0, array('a', 'b')
+ ));
+ $this->assertEquals(3, $method->invoke(null,
+ array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0), 'mustlok' => 0), array('a' => array('b' => 3)), array('a', 'b')
+ ));
+ $this->assertEquals(null, $method->invoke(null,
+ array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0, 'mustlok' => 0)), (Object) array('a' => array('b' => 3)), array('a', 'b')
+ ));
+ $this->assertEquals(3, $method->invoke(null,
+ array('scopes' => array(), 'flags' => array('prop' => 1, 'method' => 0, 'mustlok' => 0)), (Object) array('a' => array('b' => 3)), array('a', 'b')
+ ));
+ }
+ /**
+ * @covers LCRun3::ifvar
+ */
+ public function testOn_ifvar() {
+ $method = new ReflectionMethod('LCRun3', 'ifvar');
+ $this->assertEquals(false, $method->invoke(null,
+ array(), null
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array(), 0
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array(), false
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(), true
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(), 1
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array(), ''
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array(), array()
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(), array('')
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(), array(0)
+ ));
+ }
+ /**
+ * @covers LCRun3::ifv
+ */
+ public function testOn_ifv() {
+ $method = new ReflectionMethod('LCRun3', 'ifv');
+ $this->assertEquals('', $method->invoke(null,
+ array('scopes' => array()), null, array(), null
+ ));
+ $this->assertEquals('', $method->invoke(null,
+ array('scopes' => array()), null, array(), function () {return 'Y';}
+ ));
+ $this->assertEquals('Y', $method->invoke(null,
+ array('scopes' => array()), 1, array(), function () {return 'Y';}
+ ));
+ $this->assertEquals('N', $method->invoke(null,
+ array('scopes' => array()), null, array(), function () {return 'Y';}, function () {return 'N';}
+ ));
+ }
+ /**
+ * @covers LCRun3::unl
+ */
+ public function testOn_unl() {
+ $method = new ReflectionMethod('LCRun3', 'unl');
+ $this->assertEquals('', $method->invoke(null,
+ array('scopes' => array()), null, array(), null
+ ));
+ $this->assertEquals('Y', $method->invoke(null,
+ array('scopes' => array()), null, array(), function () {return 'Y';}
+ ));
+ $this->assertEquals('', $method->invoke(null,
+ array('scopes' => array()), 1, array(), function () {return 'Y';}
+ ));
+ $this->assertEquals('Y', $method->invoke(null,
+ array('scopes' => array()), null, array(), function () {return 'Y';}, function () {return 'N';}
+ ));
+ $this->assertEquals('N', $method->invoke(null,
+ array('scopes' => array()), true, array(), function () {return 'Y';}, function () {return 'N';}
+ ));
+ }
+ /**
+ * @covers LCRun3::isec
+ */
+ public function testOn_isec() {
+ $method = new ReflectionMethod('LCRun3', 'isec');
+ $this->assertEquals(true, $method->invoke(null,
+ array(), null
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array(), 0
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(), false
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array(), 'false'
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(), array()
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array(), array('1')
+ ));
+ }
+ /**
+ * @covers LCRun3::raw
+ */
+ public function testOn_raw() {
+ $method = new ReflectionMethod('LCRun3', 'raw');
+ $this->assertEquals(true, $method->invoke(null,
+ array('flags' => array('jstrue' => 0)), true
+ ));
+ $this->assertEquals('true', $method->invoke(null,
+ array('flags' => array('jstrue' => 1)), true
+ ));
+ $this->assertEquals('', $method->invoke(null,
+ array('flags' => array('jstrue' => 0)), false
+ ));
+ $this->assertEquals('false', $method->invoke(null,
+ array('flags' => array('jstrue' => 1)), false
+ ));
+ $this->assertEquals('false', $method->invoke(null,
+ array('flags' => array('jstrue' => 1)), false, true
+ ));
+ $this->assertEquals('Array', $method->invoke(null,
+ array('flags' => array('jstrue' => 1, 'jsobj' => 0)), array('a', 'b')
+ ));
+ $this->assertEquals('a,b', $method->invoke(null,
+ array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('a', 'b')
+ ));
+ $this->assertEquals('[object Object]', $method->invoke(null,
+ array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('a', 'c' => 'b')
+ ));
+ $this->assertEquals('[object Object]', $method->invoke(null,
+ array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('c' => 'b')
+ ));
+ $this->assertEquals('a,true', $method->invoke(null,
+ array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('a', true)
+ ));
+ $this->assertEquals('a,1', $method->invoke(null,
+ array('flags' => array('jstrue' => 0, 'jsobj' => 1)), array('a',true)
+ ));
+ $this->assertEquals('a,', $method->invoke(null,
+ array('flags' => array('jstrue' => 0, 'jsobj' => 1)), array('a',false)
+ ));
+ $this->assertEquals('a,false', $method->invoke(null,
+ array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('a',false)
+ ));
+ }
+ /**
+ * @covers LCRun3::enc
+ */
+ public function testOn_enc() {
+ $method = new ReflectionMethod('LCRun3', 'enc');
+ $this->assertEquals('a', $method->invoke(null,
+ array(), 'a'
+ ));
+ $this->assertEquals('a&amp;b', $method->invoke(null,
+ array(), 'a&b'
+ ));
+ $this->assertEquals('a&#039;b', $method->invoke(null,
+ array(), 'a\'b'
+ ));
+ }
+ /**
+ * @covers LCRun3::encq
+ */
+ public function testOn_encq() {
+ $method = new ReflectionMethod('LCRun3', 'encq');
+ $this->assertEquals('a', $method->invoke(null,
+ array(), 'a'
+ ));
+ $this->assertEquals('a&amp;b', $method->invoke(null,
+ array(), 'a&b'
+ ));
+ $this->assertEquals('a&#x27;b', $method->invoke(null,
+ array(), 'a\'b'
+ ));
+ $this->assertEquals('&#x60;a&#x27;b', $method->invoke(null,
+ array(), '`a\'b'
+ ));
+ }
+ /**
+ * @covers LCRun3::sec
+ */
+ public function testOn_sec() {
+ $method = new ReflectionMethod('LCRun3', 'sec');
+ $this->assertEquals('', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), false, false, false, function () {return 'A';}
+ ));
+ $this->assertEquals('', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), null, null, false, function () {return 'A';}
+ ));
+ $this->assertEquals('A', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), true, true, false, function () {return 'A';}
+ ));
+ $this->assertEquals('A', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), 0, 0, false, function () {return 'A';}
+ ));
+ $this->assertEquals('-a=', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), array('a'), array('a'), false, function ($c, $i) {return "-$i=";}
+ ));
+ $this->assertEquals('-a=-b=', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), array('a','b'), array('a','b'), false, function ($c, $i) {return "-$i=";}
+ ));
+ $this->assertEquals('', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), 'abc', 'abc', true, function ($c, $i) {return "-$i=";}
+ ));
+ $this->assertEquals('-b=', $method->invoke(null,
+ array('flags' => array('spvar' => 0, 'mustsec' => 0)), array('a' => 'b'), array('a' => 'b'), true, function ($c, $i) {return "-$i=";}
+ ));
+ $this->assertEquals('1', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), 'b', 'b', false, function ($c, $i) {return count($i);}
+ ));
+ $this->assertEquals('1', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), 1, 1, false, function ($c, $i) {return print_r($i, true);}
+ ));
+ $this->assertEquals('0', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), 0, 0, false, function ($c, $i) {return print_r($i, true);}
+ ));
+ $this->assertEquals('{"b":"c"}', $method->invoke(null,
+ array('flags' => array('spvar' => 0, 'mustsec' => 0)), array('b' => 'c'), array('b' => 'c'), false, function ($c, $i) {return json_encode($i);}
+ ));
+ $this->assertEquals('inv', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), array(), 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('inv', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), array(), 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('inv', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), false, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('inv', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), false, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('inv', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), '', 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('cb', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), '', 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('inv', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), 0, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('cb', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), 0, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('inv', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), new stdClass, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('cb', $method->invoke(null,
+ array('flags' => array('spvar' => 0)), new stdClass, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';}
+ ));
+ $this->assertEquals('268', $method->invoke(null,
+ array('flags' => array('spvar' => 1)), array(1,3,4), 0, false, function ($c, $i) {return $i * 2;}
+ ));
+ $this->assertEquals('038', $method->invoke(null,
+ array('flags' => array('spvar' => 1), 'sp_vars'=>array()), array(1,3,'a'=>4), 0, true, function ($c, $i) {return $i * $c['sp_vars']['index'];}
+ ));
+ }
+ /**
+ * @covers LCRun3::wi
+ */
+ public function testOn_wi() {
+ $method = new ReflectionMethod('LCRun3', 'wi');
+ $this->assertEquals('', $method->invoke(null,
+ array(), false, false, function () {return 'A';}
+ ));
+ $this->assertEquals('', $method->invoke(null,
+ array(), null, null, function () {return 'A';}
+ ));
+ $this->assertEquals('-Array=', $method->invoke(null,
+ array(), array('a'=>'b'), array('a' => 'b'), function ($c, $i) {return "-$i=";}
+ ));
+ $this->assertEquals('-b=', $method->invoke(null,
+ array(), 'b', array('a' => 'b'), function ($c, $i) {return "-$i=";}
+ ));
+ }
+ /**
+ * @covers LCRun3::ch
+ */
+ public function testOn_ch() {
+ $method = new ReflectionMethod('LCRun3', 'ch');
+ $this->assertEquals('=-=', $method->invoke(null,
+ array('helpers' => array('a' => function ($i) {return "=$i[0]=";})), 'a', array(array('-'),array()), 'raw'
+ ));
+ $this->assertEquals('=&amp;=', $method->invoke(null,
+ array('helpers' => array('a' => function ($i) {return "=$i[0]=";})), 'a', array(array('&'),array()), 'enc'
+ ));
+ $this->assertEquals('=&#x27;=', $method->invoke(null,
+ array('helpers' => array('a' => function ($i) {return "=$i[0]=";})), 'a', array(array('\''),array()), 'encq'
+ ));
+ $this->assertEquals('=b=', $method->invoke(null,
+ array('helpers' => array('a' => function ($i,$j) {return "={$j['a']}=";})), 'a', array(array(),array('a' => 'b')), 'raw'
+ ));
+ }
+ /**
+ * @covers LCRun3::chret
+ */
+ public function testOn_chret() {
+ $method = new ReflectionMethod('LCRun3', 'chret');
+ $this->assertEquals('=&=', $method->invoke(null,
+ '=&=', 'raw'
+ ));
+ $this->assertEquals('=&amp;&#039;=', $method->invoke(null,
+ '=&\'=', 'enc'
+ ));
+ $this->assertEquals('=&amp;&#x27;=', $method->invoke(null,
+ '=&\'=', 'encq'
+ ));
+ $this->assertEquals('=&amp;&#039;=', $method->invoke(null,
+ array('=&\'='), 'enc'
+ ));
+ $this->assertEquals('=&amp;&#x27;=', $method->invoke(null,
+ array('=&\'='), 'encq'
+ ));
+ $this->assertEquals('=&amp;=', $method->invoke(null,
+ array('=&=', false), 'enc'
+ ));
+ $this->assertEquals('=&=', $method->invoke(null,
+ array('=&=', false), 'raw'
+ ));
+ $this->assertEquals('=&=', $method->invoke(null,
+ array('=&=', 'raw'), 'enc'
+ ));
+ $this->assertEquals('=&amp;&#x27;=', $method->invoke(null,
+ array('=&\'=', 'encq'), 'raw'
+ ));
+ }
+ /**
+ * @covers LCRun3::bch
+ */
+ public function testOn_bch() {
+ $method = new ReflectionMethod('LCRun3', 'bch');
+ $this->assertEquals('4.2.3', $method->invoke(null,
+ array('blockhelpers' => array('a' => function ($cx) {return array($cx,2,3);})), 'a', array(0, 0), 4, false, function($cx, $i) {return implode('.', $i);}
+ ));
+ $this->assertEquals('2.6.5', $method->invoke(null,
+ array('blockhelpers' => array('a' => function ($cx,$in) {return array($cx,$in[0],5);})), 'a', array('6', 0), 2, false, function($cx, $i) {return implode('.', $i);}
+ ));
+ $this->assertEquals('', $method->invoke(null,
+ array('blockhelpers' => array('a' => function ($cx,$in) {})), 'a', array('6', 0), 2, false, function($cx, $i) {return implode('.', $i);}
+ ));
+ }
+}
+?> \ No newline at end of file
diff --git a/vendor/zordius/lightncandy/tests/LightnCandyTest.php b/vendor/zordius/lightncandy/tests/LightnCandyTest.php
new file mode 100644
index 00000000..6f82f2bd
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/LightnCandyTest.php
@@ -0,0 +1,460 @@
+<?php
+/**
+ * Generated by build/gen_test
+ */
+require_once('src/lightncandy.php');
+
+class LightnCandyTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @covers LightnCandy::buildHelperTable
+ */
+ public function testOn_buildHelperTable() {
+ $method = new ReflectionMethod('LightnCandy', 'buildHelperTable');
+ $method->setAccessible(true);
+ $this->assertEquals(array(), $method->invoke(null,
+ array(), array()
+ ));
+ $this->assertEquals(array('flags' => array('exhlp' => 1)), $method->invoke(null,
+ array('flags' => array('exhlp' => 1)), array('helpers' => array('abc'))
+ ));
+ $this->assertEquals(array('error' => array('Can not find custom helper function defination abc() !'), 'flags' => array('exhlp' => 0)), $method->invoke(null,
+ array('error' => array(), 'flags' => array('exhlp' => 0)), array('helpers' => array('abc'))
+ ));
+ $this->assertEquals(array('flags' => array('exhlp' => 1), 'helpers' => array('LCRun3::raw' => 'LCRun3::raw')), $method->invoke(null,
+ array('flags' => array('exhlp' => 1), 'helpers' => array()), array('helpers' => array('LCRun3::raw'))
+ ));
+ $this->assertEquals(array('flags' => array('exhlp' => 1), 'helpers' => array('test' => 'LCRun3::raw')), $method->invoke(null,
+ array('flags' => array('exhlp' => 1), 'helpers' => array()), array('helpers' => array('test' => 'LCRun3::raw'))
+ ));
+ }
+ /**
+ * @covers LightnCandy::buildCXFileext
+ */
+ public function testOn_buildCXFileext() {
+ $method = new ReflectionMethod('LightnCandy', 'buildCXFileext');
+ $method->setAccessible(true);
+ $this->assertEquals(array('.tmpl'), $method->invoke(null,
+ array()
+ ));
+ $this->assertEquals(array('test'), $method->invoke(null,
+ array('fileext' => 'test')
+ ));
+ $this->assertEquals(array('test1'), $method->invoke(null,
+ array('fileext' => array('test1'))
+ ));
+ $this->assertEquals(array('test2', 'test3'), $method->invoke(null,
+ array('fileext' => array('test2', 'test3'))
+ ));
+ }
+ /**
+ * @covers LightnCandy::buildCXBasedir
+ */
+ public function testOn_buildCXBasedir() {
+ $method = new ReflectionMethod('LightnCandy', 'buildCXBasedir');
+ $method->setAccessible(true);
+ $this->assertEquals(array(), $method->invoke(null,
+ array()
+ ));
+ $this->assertEquals(array(), $method->invoke(null,
+ array('basedir' => array())
+ ));
+ $this->assertEquals(array('src'), $method->invoke(null,
+ array('basedir' => array('src'))
+ ));
+ $this->assertEquals(array('src'), $method->invoke(null,
+ array('basedir' => array('src', 'dir_not_found'))
+ ));
+ $this->assertEquals(array('src', 'tests'), $method->invoke(null,
+ array('basedir' => array('src', 'tests'))
+ ));
+ }
+ /**
+ * @covers LightnCandy::getPHPCode
+ */
+ public function testOn_getPHPCode() {
+ $method = new ReflectionMethod('LightnCandy', 'getPHPCode');
+ $method->setAccessible(true);
+ $this->assertEquals('function($a) {return;}', $method->invoke(null,
+ function ($a) {return;}
+ ));
+ $this->assertEquals('function($a) {return;}', $method->invoke(null,
+ function ($a) {return;}
+ ));
+ }
+ /**
+ * @covers LightnCandy::handleError
+ */
+ public function testOn_handleError() {
+ $method = new ReflectionMethod('LightnCandy', 'handleError');
+ $method->setAccessible(true);
+ $this->assertEquals(true, $method->invoke(null,
+ array('level' => 1, 'stack' => array('X'), 'flags' => array('errorlog' => 0, 'exception' => 0), 'error' => array())
+ ));
+ $this->assertEquals(false, $method->invoke(null,
+ array('level' => 0, 'error' => array())
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array('level' => 0, 'error' => array('some error'), 'flags' => array('errorlog' => 0, 'exception' => 0))
+ ));
+ }
+ /**
+ * @covers LightnCandy::getBoolStr
+ */
+ public function testOn_getBoolStr() {
+ $method = new ReflectionMethod('LightnCandy', 'getBoolStr');
+ $method->setAccessible(true);
+ $this->assertEquals('true', $method->invoke(null,
+ 1
+ ));
+ $this->assertEquals('true', $method->invoke(null,
+ 999
+ ));
+ $this->assertEquals('false', $method->invoke(null,
+ 0
+ ));
+ $this->assertEquals('false', $method->invoke(null,
+ -1
+ ));
+ }
+ /**
+ * @covers LightnCandy::getFuncName
+ */
+ public function testOn_getFuncName() {
+ $method = new ReflectionMethod('LightnCandy', 'getFuncName');
+ $method->setAccessible(true);
+ $this->assertEquals('LCRun3::test(', $method->invoke(null,
+ array('flags' => array('standalone' => 0, 'debug' => 0)), 'test', ''
+ ));
+ $this->assertEquals('LCRun3::test2(', $method->invoke(null,
+ array('flags' => array('standalone' => 0, 'debug' => 0)), 'test2', ''
+ ));
+ $this->assertEquals("\$cx['funcs']['test3'](", $method->invoke(null,
+ array('flags' => array('standalone' => 1, 'debug' => 0)), 'test3', ''
+ ));
+ $this->assertEquals('LCRun3::debug(\'abc\', \'test\', ', $method->invoke(null,
+ array('flags' => array('standalone' => 0, 'debug' => 1)), 'test', 'abc'
+ ));
+ }
+ /**
+ * @covers LightnCandy::getArrayStr
+ */
+ public function testOn_getArrayStr() {
+ $method = new ReflectionMethod('LightnCandy', 'getArrayStr');
+ $method->setAccessible(true);
+ $this->assertEquals('', $method->invoke(null,
+ array()
+ ));
+ $this->assertEquals('[a]', $method->invoke(null,
+ array('a')
+ ));
+ $this->assertEquals('[a][b][c]', $method->invoke(null,
+ array('a', 'b', 'c')
+ ));
+ }
+ /**
+ * @covers LightnCandy::getArrayCode
+ */
+ public function testOn_getArrayCode() {
+ $method = new ReflectionMethod('LightnCandy', 'getArrayCode');
+ $method->setAccessible(true);
+ $this->assertEquals('', $method->invoke(null,
+ array()
+ ));
+ $this->assertEquals("['a']", $method->invoke(null,
+ array('a')
+ ));
+ $this->assertEquals("['a']['b']['c']", $method->invoke(null,
+ array('a', 'b', 'c')
+ ));
+ }
+ /**
+ * @covers LightnCandy::getVariableNames
+ */
+ public function testOn_getVariableNames() {
+ $method = new ReflectionMethod('LightnCandy', 'getVariableNames');
+ $method->setAccessible(true);
+ $this->assertEquals(array('array(array($in),array())', array('this')), $method->invoke(null,
+ array(null), array('flags'=>array('spvar'=>true))
+ ));
+ $this->assertEquals(array('array(array($in,$in),array())', array('this', 'this')), $method->invoke(null,
+ array(null, null), array('flags'=>array('spvar'=>true))
+ ));
+ $this->assertEquals(array('array(array(),array(\'a\'=>$in))', array('this')), $method->invoke(null,
+ array('a' => null), array('flags'=>array('spvar'=>true))
+ ));
+ }
+ /**
+ * @covers LightnCandy::getVariableName
+ */
+ public function testOn_getVariableName() {
+ $method = new ReflectionMethod('LightnCandy', 'getVariableName');
+ $method->setAccessible(true);
+ $this->assertEquals(array('$in', 'this'), $method->invoke(null,
+ array(null), array('flags'=>array('spvar'=>true,'debug'=>0))
+ ));
+ $this->assertEquals(array('true', 'true'), $method->invoke(null,
+ array('true'), array('flags'=>array('spvar'=>true,'debug'=>0)), true
+ ));
+ $this->assertEquals(array('false', 'false'), $method->invoke(null,
+ array('false'), array('flags'=>array('spvar'=>true,'debug'=>0)), true
+ ));
+ $this->assertEquals(array(2, '2'), $method->invoke(null,
+ array('2'), array('flags'=>array('spvar'=>true,'debug'=>0)), true
+ ));
+ $this->assertEquals(array('((isset($in[\'@index\']) && is_array($in)) ? $in[\'@index\'] : null)', '[@index]'), $method->invoke(null,
+ array('@index'), array('flags'=>array('spvar'=>false,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0))
+ ));
+ $this->assertEquals(array("((isset(\$cx['sp_vars']['index']) && is_array(\$cx['sp_vars'])) ? \$cx['sp_vars']['index'] : null)", '@[index]'), $method->invoke(null,
+ array('@index'), array('flags'=>array('spvar'=>true,'debug'=>0))
+ ));
+ $this->assertEquals(array("((isset(\$cx['sp_vars']['key']) && is_array(\$cx['sp_vars'])) ? \$cx['sp_vars']['key'] : null)", '@[key]'), $method->invoke(null,
+ array('@key'), array('flags'=>array('spvar'=>true,'debug'=>0))
+ ));
+ $this->assertEquals(array("((isset(\$cx['sp_vars']['first']) && is_array(\$cx['sp_vars'])) ? \$cx['sp_vars']['first'] : null)", '@[first]'), $method->invoke(null,
+ array('@first'), array('flags'=>array('spvar'=>true,'debug'=>0))
+ ));
+ $this->assertEquals(array("((isset(\$cx['sp_vars']['last']) && is_array(\$cx['sp_vars'])) ? \$cx['sp_vars']['last'] : null)", '@[last]'), $method->invoke(null,
+ array('@last'), array('flags'=>array('spvar'=>true,'debug'=>0))
+ ));
+ $this->assertEquals(array('\'a\'', '"a"'), $method->invoke(null,
+ array('"a"'), array('flags'=>array('spvar'=>true,'debug'=>0))
+ ));
+ $this->assertEquals(array('((isset($in[\'a\']) && is_array($in)) ? $in[\'a\'] : null)', '[a]'), $method->invoke(null,
+ array('a'), array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0))
+ ));
+ $this->assertEquals(array('((isset($cx[\'scopes\'][count($cx[\'scopes\'])-1][\'a\']) && is_array($cx[\'scopes\'][count($cx[\'scopes\'])-1])) ? $cx[\'scopes\'][count($cx[\'scopes\'])-1][\'a\'] : null)', '../[a]'), $method->invoke(null,
+ array(1,'a'), array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0))
+ ));
+ $this->assertEquals(array('((isset($cx[\'scopes\'][count($cx[\'scopes\'])-3][\'a\']) && is_array($cx[\'scopes\'][count($cx[\'scopes\'])-3])) ? $cx[\'scopes\'][count($cx[\'scopes\'])-3][\'a\'] : null)', '../../../[a]'), $method->invoke(null,
+ array(3,'a'), array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0))
+ ));
+ $this->assertEquals(array('((isset($in[\'id\']) && is_array($in)) ? $in[\'id\'] : null)', 'this.[id]'), $method->invoke(null,
+ array(null, 'id'), array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0))
+ ));
+ $this->assertEquals(array('LCRun3::v($cx, $in, array(\'id\'))', 'this.[id]'), $method->invoke(null,
+ array(null, 'id'), array('flags'=>array('prop'=>true,'spvar'=>true,'debug'=>0,'method'=>0,'mustlok'=>0,'standalone'=>0))
+ ));
+ }
+ /**
+ * @covers LightnCandy::getExpression
+ */
+ public function testOn_getExpression() {
+ $method = new ReflectionMethod('LightnCandy', 'getExpression');
+ $method->setAccessible(true);
+ $this->assertEquals('[a].[b]', $method->invoke(null,
+ 0, false, array('a', 'b')
+ ));
+ $this->assertEquals('@[root]', $method->invoke(null,
+ 0, true, array('root')
+ ));
+ $this->assertEquals('this', $method->invoke(null,
+ 0, false, null
+ ));
+ $this->assertEquals('this.[id]', $method->invoke(null,
+ 0, false, array(null, 'id')
+ ));
+ $this->assertEquals('@[root].[a].[b]', $method->invoke(null,
+ 0, true, array('root', 'a', 'b')
+ ));
+ $this->assertEquals('../../[a].[b]', $method->invoke(null,
+ 2, false, array('a', 'b')
+ ));
+ $this->assertEquals('../[a\'b]', $method->invoke(null,
+ 1, false, array('a\'b')
+ ));
+ }
+ /**
+ * @covers LightnCandy::fixVariable
+ */
+ public function testOn_fixVariable() {
+ $method = new ReflectionMethod('LightnCandy', 'fixVariable');
+ $method->setAccessible(true);
+ $this->assertEquals(array('this'), $method->invoke(null,
+ 'this', array('flags' => array('advar' => 0, 'this' => 0))
+ ));
+ $this->assertEquals(array(null), $method->invoke(null,
+ 'this', array('flags' => array('advar' => 0, 'this' => 1))
+ ));
+ $this->assertEquals(array(1, null), $method->invoke(null,
+ '../', array('flags' => array('advar' => 0, 'this' => 1, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array(1, null), $method->invoke(null,
+ '../.', array('flags' => array('advar' => 0, 'this' => 1, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array(1, null), $method->invoke(null,
+ '../this', array('flags' => array('advar' => 0, 'this' => 1, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array(1, 'a'), $method->invoke(null,
+ '../a', array('flags' => array('advar' => 0, 'this' => 1, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array(2, 'a', 'b'), $method->invoke(null,
+ '../../a.b', array('flags' => array('advar' => 0, 'this' => 0, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array(2, '[a]', 'b'), $method->invoke(null,
+ '../../[a].b', array('flags' => array('advar' => 0, 'this' => 0, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array(2, 'a', 'b'), $method->invoke(null,
+ '../../[a].b', array('flags' => array('advar' => 1, 'this' => 0, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array('"a.b"'), $method->invoke(null,
+ '"a.b"', array('flags' => array('advar' => 1, 'this' => 0, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ $this->assertEquals(array(null, 'id'), $method->invoke(null,
+ 'this.id', array('flags' => array('advar' => 1, 'this' => 1, 'parent' => 1), 'usedFeature' => array('parent' => 0))
+ ));
+ }
+ /**
+ * @covers LightnCandy::parseTokenArgs
+ */
+ public function testOn_parseTokenArgs() {
+ $method = new ReflectionMethod('LightnCandy', 'parseTokenArgs');
+ $method->setAccessible(true);
+ $this->assertEquals(array(false, array(array(null))), $method->invoke(null,
+ array(0,0,0,0,0,0,''), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(true, array(array(null))), $method->invoke(null,
+ array(0,0,0,'{{{',0,0,''), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(true, array(array(null))), $method->invoke(null,
+ array(0,0,0,0,0,0,''), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 0, 'noesc' => 1))
+ ));
+ $this->assertEquals(array(false, array(array('a'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a'), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('b'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a b'), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('"b'), array('c"'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a "b c"'), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('"b c"'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a "b c"'), array('flags' => array('advar' => 1, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('[b'), array('c]'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a [b c]'), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('[b'), array('c]'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a [b c]'), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('b c'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a [b c]'), array('flags' => array('advar' => 1, 'this' => 1, 'namev' => 0, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('b c'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a [b c]'), array('flags' => array('advar' => 1, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), 'q' => array('b c'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a q=[b c]'), array('flags' => array('advar' => 1, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), array('q=[b c'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a [q=[b c]'), array('flags' => array('advar' => 1, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), 'q' => array('[b'), array('c]'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a q=[b c]'), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), 'q' => array('b'), array('c'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a [q]=b c'), array('flags' => array('advar' => 0, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('a'), 'q' => array('"b c"'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'a q="b c"'), array('flags' => array('advar' => 1, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('(foo bar)'))), $method->invoke(null,
+ array(0,0,0,0,0,0,'(foo bar)'), array('flags' => array('advar' => 1, 'this' => 1, 'namev' => 1, 'noesc' => 0))
+ ));
+ $this->assertEquals(array(false, array(array('foo'), array("'=='"), array('bar'))), $method->invoke(null,
+ array(0,0,0,0,0,0,"foo '==' bar"), array('flags' => array('advar' => 1, 'namev' => 1))
+ ));
+ }
+ /**
+ * @covers LightnCandy::tokenString
+ */
+ public function testOn_tokenString() {
+ $method = new ReflectionMethod('LightnCandy', 'tokenString');
+ $method->setAccessible(true);
+ $this->assertEquals('b', $method->invoke(null,
+ array(0, 'a', 'b', 'c'), 1
+ ));
+ $this->assertEquals('c', $method->invoke(null,
+ array(0, 'a', 'b', 'c', 'd', 'e')
+ ));
+ }
+ /**
+ * @covers LightnCandy::validateStartEnd
+ */
+ public function testOn_validateStartEnd() {
+ $method = new ReflectionMethod('LightnCandy', 'validateStartEnd');
+ $method->setAccessible(true);
+ $this->assertEquals(null, $method->invoke(null,
+ array_fill(0, 9, ''), array()
+ ));
+ $this->assertEquals(null, $method->invoke(null,
+ array_fill(0, 9, '}}'), array()
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array_fill(0, 9, '{{{'), array()
+ ));
+ }
+ /**
+ * @covers LightnCandy::validateOperations
+ */
+ public function testOn_validateOperations() {
+ $method = new ReflectionMethod('LightnCandy', 'validateOperations');
+ $method->setAccessible(true);
+ $this->assertEquals(null, $method->invoke(null,
+ array(0, 0, 0, 0, 0, ''), array(), array()
+ ));
+ $this->assertEquals(2, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '^', '...'), array('usedFeature' => array('isec' => 1), 'level' => 0), array(array('foo'))
+ ));
+ $this->assertEquals(3, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '!', '...'), array('usedFeature' => array('comment' => 2)), array()
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '/'), array('stack' => array(1), 'level' => 1), array()
+ ));
+ $this->assertEquals(4, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '#', '...'), array('usedFeature' => array('sec' => 3), 'level' => 0), array(array('x'))
+ ));
+ $this->assertEquals(5, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '#', '...'), array('usedFeature' => array('if' => 4), 'level' => 0), array(array('if'))
+ ));
+ $this->assertEquals(6, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '#', '...'), array('usedFeature' => array('with' => 5), 'level' => 0, 'flags' => array('with' => 1)), array(array('with'))
+ ));
+ $this->assertEquals(7, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '#', '...'), array('usedFeature' => array('each' => 6), 'level' => 0), array(array('each'))
+ ));
+ $this->assertEquals(8, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '#', '...'), array('usedFeature' => array('unless' => 7), 'level' => 0), array(array('unless'))
+ ));
+ $this->assertEquals(9, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '#', '...'), array('blockhelpers' => array('abc' => ''), 'usedFeature' => array('bhelper' => 8), 'level' => 0), array(array('abc'))
+ ));
+ $this->assertEquals(10, $method->invoke(null,
+ array(0, 0, 0, 0, 0, ' ', '...'), array('usedFeature' => array('delimiter' => 9), 'level' => 0), array()
+ ));
+ $this->assertEquals(11, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '#', '...'), array('hbhelpers' => array('abc' => ''), 'usedFeature' => array('hbhelper' => 10), 'level' => 0), array(array('abc'))
+ ));
+ $this->assertEquals(true, $method->invoke(null,
+ array(0, 0, 0, 0, 0, '>', '...'), array('basedir' => array('.'), 'fileext' => array('.tmpl'), 'usedFeature' => array('unless' => 7, 'partial' => 7), 'level' => 0, 'flags' => array('skippartial' => 0)), array('test')
+ ));
+ }
+ /**
+ * @covers LightnCandy::addUsageCount
+ */
+ public function testOn_addUsageCount() {
+ $method = new ReflectionMethod('LightnCandy', 'addUsageCount');
+ $method->setAccessible(true);
+ $this->assertEquals(1, $method->invoke(null,
+ array('usedCount' => array('test' => array())), 'test', 'testname'
+ ));
+ $this->assertEquals(3, $method->invoke(null,
+ array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname'
+ ));
+ $this->assertEquals(5, $method->invoke(null,
+ array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname', 3
+ ));
+ }
+}
+?> \ No newline at end of file
diff --git a/vendor/zordius/lightncandy/tests/errorTest.php b/vendor/zordius/lightncandy/tests/errorTest.php
new file mode 100644
index 00000000..30ecd97d
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/errorTest.php
@@ -0,0 +1,410 @@
+<?php
+
+require_once('src/lightncandy.php');
+require_once('tests/helpers_for_test.php');
+
+$tmpdir = sys_get_temp_dir();
+$errlog_fn = tempnam($tmpdir, 'terr_');
+
+function start_catch_error_log() {
+ global $errlog_fn;
+ date_default_timezone_set('GMT');
+ if (file_exists($errlog_fn)) {
+ unlink($errlog_fn);
+ }
+ return ini_set('error_log', $errlog_fn);
+}
+
+function stop_catch_error_log() {
+ global $errlog_fn;
+ ini_restore('error_log');
+ if (!file_exists($errlog_fn)) {
+ return null;
+ }
+ return array_map(function ($l) {
+ $l = rtrim($l);
+ preg_match('/GMT\] (.+)/', $l, $m);
+ return isset($m[1]) ? $m[1] : $l;
+ }, file($errlog_fn));
+}
+
+class errorTest extends PHPUnit_Framework_TestCase
+{
+ public function testException()
+ {
+ $this->setExpectedException('Exception', 'Bad token {{{foo}} ! Do you mean {{foo}} or {{{foo}}}?');
+ $php = LightnCandy::compile('{{{foo}}', Array('flags' => LightnCandy::FLAG_ERROR_EXCEPTION));
+ }
+
+ public function testErrorLog()
+ {
+ start_catch_error_log();
+ $php = LightnCandy::compile('{{{foo}}', Array('flags' => LightnCandy::FLAG_ERROR_LOG));
+ $e = stop_catch_error_log();
+ if ($e) {
+ $this->assertEquals(Array('Bad token {{{foo}} ! Do you mean {{foo}} or {{{foo}}}?'), $e);
+ } else {
+ $this->markTestIncomplete('skip HHVM');
+ }
+ }
+
+ /**
+ * @dataProvider renderErrorProvider
+ */
+ public function testRenderingException($test)
+ {
+ $this->setExpectedException('Exception', $test['expected']);
+ $php = LightnCandy::compile($test['template'], $test['options']);
+ $renderer = LightnCandy::prepare($php);
+ $renderer(null, LCRun3::DEBUG_ERROR_EXCEPTION);
+ }
+
+ /**
+ * @dataProvider renderErrorProvider
+ */
+ public function testRenderingErrorLog($test)
+ {
+ start_catch_error_log();
+ $php = LightnCandy::compile($test['template'], $test['options']);
+ $renderer = LightnCandy::prepare($php);
+ $renderer(null, LCRun3::DEBUG_ERROR_LOG);
+ $e = stop_catch_error_log();
+ if ($e) {
+ $this->assertEquals(Array($test['expected']), $e);
+ } else {
+ $this->markTestIncomplete('skip HHVM');
+ }
+ }
+
+ public function renderErrorProvider()
+ {
+ $errorCases = Array(
+ Array(
+ 'template' => '{{{foo}}}',
+ 'expected' => 'LCRun3: [foo] is not exist',
+ ),
+ Array(
+ 'template' => '{{foo}}',
+ 'options' => Array(
+ 'hbhelpers' => Array(
+ 'foo' => function () {
+ return 1/0;
+ }
+ ),
+ ),
+ 'expected' => 'LCRun3: call custom helper \'foo\' error: Division by zero',
+ ),
+ );
+
+ return array_map(function($i) {
+ if (!isset($i['options'])) {
+ $i['options'] = Array('flags' => LightnCandy::FLAG_RENDER_DEBUG);
+ }
+ if (!isset($i['options']['flags'])) {
+ $i['options']['flags'] = LightnCandy::FLAG_RENDER_DEBUG;
+ }
+ return Array($i);
+ }, $errorCases);
+ }
+
+ /**
+ * @dataProvider errorProvider
+ */
+ public function testErrors($test)
+ {
+ global $tmpdir;
+
+ $php = LightnCandy::compile($test['template'], $test['options']);
+ $context = LightnCandy::getContext();
+
+ // This case should be compiled without error
+ if (!isset($test['expected'])) {
+ return;
+ }
+
+ $this->assertEquals($test['expected'], $context['error'], "Code: $php");
+ }
+
+ public function errorProvider()
+ {
+ $errorCases = Array(
+ Array(
+ 'template' => '{{testerr1}}}',
+ 'expected' => 'Bad token {{testerr1}}} ! Do you mean {{testerr1}} or {{{testerr1}}}?',
+ ),
+ Array(
+ 'template' => '{{{testerr2}}',
+ 'expected' => 'Bad token {{{testerr2}} ! Do you mean {{testerr2}} or {{{testerr2}}}?',
+ ),
+ Array(
+ 'template' => '{{{#testerr3}}}',
+ 'expected' => 'Bad token {{{#testerr3}}} ! Do you mean {{#testerr3}} ?',
+ ),
+ Array(
+ 'template' => '{{{!testerr4}}}',
+ 'expected' => 'Bad token {{{!testerr4}}} ! Do you mean {{!testerr4}} ?',
+ ),
+ Array(
+ 'template' => '{{{^testerr5}}}',
+ 'expected' => 'Bad token {{{^testerr5}}} ! Do you mean {{^testerr5}} ?',
+ ),
+ Array(
+ 'template' => '{{{/testerr6}}}',
+ 'expected' => 'Bad token {{{/testerr6}}} ! Do you mean {{/testerr6}} ?',
+ ),
+ Array(
+ 'template' => '{{win[ner.test1}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming in {{win[ner.test1}}',
+ ),
+ Array(
+ 'template' => '{{win]ner.test2}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'win]ner.test2\' in {{win]ner.test2}} !',
+ ),
+ Array(
+ 'template' => '{{wi[n]ner.test3}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'wi[n]ner.test3\' in {{wi[n]ner.test3}} !',
+ ),
+ Array(
+ 'template' => '{{winner].[test4]}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'winner].[test4]\' in {{winner].[test4]}} !',
+ ),
+ Array(
+ 'template' => '{{winner[.test5]}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'winner[.test5]\' in {{winner[.test5]}} !',
+ ),
+ Array(
+ 'template' => '{{winner.[.test6]}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{winner.[#te.st7]}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{test8}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{test9]}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'test9]\' in {{test9]}} !',
+ ),
+ Array(
+ 'template' => '{{testA[}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'testA[\' in {{testA[}} !',
+ ),
+ Array(
+ 'template' => '{{[testB}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming in {{[testB}}',
+ ),
+ Array(
+ 'template' => '{{]testC}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \']testC\' in {{]testC}} !',
+ ),
+ Array(
+ 'template' => '{{[testD]}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{te]stE}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'te]stE\' in {{te]stE}} !',
+ ),
+ Array(
+ 'template' => '{{tee[stF}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming in {{tee[stF}}',
+ ),
+ Array(
+ 'template' => '{{te.e[stG}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming in {{te.e[stG}}',
+ ),
+ Array(
+ 'template' => '{{te.e]stH}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'te.e]stH\' in {{te.e]stH}} !',
+ ),
+ Array(
+ 'template' => '{{te.e[st.endI}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming in {{te.e[st.endI}}',
+ ),
+ Array(
+ 'template' => '{{te.e]st.endJ}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'te.e]st.endJ\' in {{te.e]st.endJ}} !',
+ ),
+ Array(
+ 'template' => '{{te.[est].endK}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{te.t[est].endL}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'te.t[est].endL\' in {{te.t[est].endL}} !',
+ ),
+ Array(
+ 'template' => '{{te.t[est]o.endM}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'te.t[est]o.endM\' in {{te.t[est]o.endM}} !',
+ ),
+ Array(
+ 'template' => '{{te.[est]o.endN}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ 'expected' => 'Wrong variable naming as \'te.[est]o.endN\' in {{te.[est]o.endN}} !',
+ ),
+ Array(
+ 'template' => '{{te.[e.st].endO}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{te.[e.s[t].endP}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{te.[e[s.t].endQ}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ADVARNAME),
+ ),
+ Array(
+ 'template' => '{{helper}}',
+ 'options' => Array('helpers' => Array(
+ 'helper' => Array('bad input'),
+ )),
+ 'expected' => 'I found an array in helpers with key as helper, please fix it.',
+ ),
+ Array(
+ 'template' => '<ul>{{#each item}}<li>{{name}}</li>',
+ 'expected' => 'Unclosed token {{{#each item}}} !!',
+ ),
+ Array(
+ 'template' => 'issue63: {{test_join}} Test! {{this}} {{/test_join}}',
+ 'expected' => 'Unexpect token: {{/test_join}} !',
+ ),
+ Array(
+ 'template' => '{{#if a}}TEST{{/with}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH),
+ 'expected' => 'Unexpect token: {{/with}} !',
+ ),
+ Array(
+ 'template' => '{{#foo}}error{{/bar}}',
+ 'expected' => 'Unexpect token {{/bar}} ! Previous token {{#[foo]}} is not closed',
+ ),
+ Array(
+ 'template' => '{{../foo}}',
+ 'expected' => 'Do not support {{../var}}, you should do compile with LightnCandy::FLAG_PARENT flag',
+ ),
+ Array(
+ 'template' => '{{..}}',
+ 'expected' => 'Do not support {{../var}}, you should do compile with LightnCandy::FLAG_PARENT flag',
+ ),
+ Array(
+ 'template' => '{{test_join [a]=b}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_NAMEDARG,
+ 'helpers' => Array('test_join')
+ ),
+ 'expected' => "Wrong argument name as '[a]' in {{test_join [a]=b}} ! You should fix your template or compile with LightnCandy::FLAG_ADVARNAME flag.",
+ ),
+ Array(
+ 'template' => '{{a=b}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_NAMEDARG),
+ 'expected' => 'Do not support name=value in {{a=b}}, you should use it after a custom helper.',
+ ),
+ Array(
+ 'template' => '{{test a=b}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_NAMEDARG),
+ 'expected' => 'Do not support name=value in {{test a=b}}, maybe you missing the custom helper?',
+ ),
+ Array(
+ 'template' => '{{#test a=b}}YA~{{/test}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_NAMEDARG),
+ 'expected' => 'Do not support name=value in {{#test a=b}}, maybe you missing the block custom helper?',
+ ),
+ Array(
+ 'template' => '{{#foo}}1{{^}}2{{/foo}}',
+ 'expected' => 'Do not support {{^}}, you should do compile with LightnCandy::FLAG_ELSE flag',
+ ),
+ Array(
+ 'template' => '{{#with a}OK!{{/with}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH),
+ 'expected' => 'Unclosed token {{{#with a}OK!{{/with}}} !!',
+ ),
+ Array(
+ 'template' => '{{#each a}OK!{{/each}}',
+ 'expected' => 'Unclosed token {{{#each a}OK!{{/each}}} !!',
+ ),
+ Array(
+ 'template' => '{{#with items}}OK!{{/with}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH),
+ ),
+ Array(
+ 'template' => '{{#with}}OK!{{/with}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH),
+ 'expected' => 'No argument after {{#with}} !',
+ ),
+ Array(
+ 'template' => '{{>not_found}}',
+ 'expected' => "Can not find partial file for 'not_found', you should set correct basedir and fileext in options",
+ ),
+ Array(
+ 'template' => '{{>tests/test1 foo}}',
+ 'options' => Array('basedir' => '.'),
+ 'expected' => 'Do not support {{>tests/test1 [foo]}}, you should do compile with LightnCandy::FLAG_RUNTIMEPARTIAL flag',
+ ),
+ Array(
+ 'template' => '{{#with foo}}ABC{{/with}}',
+ 'expected' => 'Do not support {{#with var}}, you should do compile with LightnCandy::FLAG_WITH flag',
+ ),
+ Array(
+ 'template' => '{{abc}}',
+ 'options' => Array('helpers' => Array('abc')),
+ 'expected' => 'Can not find custom helper function defination abc() !',
+ ),
+ Array(
+ 'template' => '{{=~= =~=}}',
+ 'expected' => "Can not set delimiter contains '=' , you try to set delimiter as '~=' and '=~'.",
+ ),
+ Array(
+ 'template' => '{{>recursive}}',
+ 'options' => Array('basedir' => 'tests', 'flags' => LightnCandy::FLAG_WITH),
+ 'expected' => Array(
+ 'I found recursive partial includes as the path: recursive -> recursive! You should fix your template or compile with LightnCandy::FLAG_RUNTIMEPARTIAL flag.',
+ "Skip rendering partial 'recursive' again due to recursive detected",
+ )
+ ),
+ Array(
+ 'template' => '{{test_join (foo bar)}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_ADVARNAME,
+ 'helpers' => Array('test_join'),
+ ),
+ 'expected' => "Custom helper 'foo' not found!",
+ ),
+ );
+
+ return array_map(function($i) {
+ if (!isset($i['options'])) {
+ $i['options'] = Array('flags' => 0);
+ }
+ if (!isset($i['options']['flags'])) {
+ $i['options']['flags'] = 0;
+ }
+ if (isset($i['expected']) && !is_array($i['expected'])) {
+ $i['expected'] = Array($i['expected']);
+ }
+ return Array($i);
+ }, $errorCases);
+ }
+}
+
+
+?>
diff --git a/vendor/zordius/lightncandy/tests/example_debug.php b/vendor/zordius/lightncandy/tests/example_debug.php
new file mode 100644
index 00000000..bc573e0d
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/example_debug.php
@@ -0,0 +1,28 @@
+<?php
+require('src/lightncandy.php');
+
+$template = "Hello! {{name}} is {{gender}}.
+Test1: {{@root.name}}
+Test2: {{@root.gender}}
+Test3: {{../test3}}
+Test4: {{../../test4}}
+Test5: {{../../.}}
+Test6: {{../../[test'6]}}
+{{#each .}}
+each Value: {{.}}
+{{/each}}
+{{#.}}
+section Value: {{.}}
+{{/.}}
+{{#if .}}IF OK!{{/if}}
+{{#unless .}}Unless not OK!{{/unless}}
+";
+
+$php = LightnCandy::compile($template, Array(
+ 'flags' => LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_HANDLEBARSJS
+));
+
+$renderer = LightnCandy::prepare($php);
+error_reporting(0);
+echo $renderer(Array('name' => 'John'), LCRun3::DEBUG_TAGS_ANSI);
+?>
diff --git a/vendor/zordius/lightncandy/tests/example_helpers.php b/vendor/zordius/lightncandy/tests/example_helpers.php
new file mode 100644
index 00000000..f5e67d6f
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/example_helpers.php
@@ -0,0 +1,58 @@
+<?php
+
+// Custom Helper Interface ... noname arguments
+// Template: {{helper1 article.url article.text}}
+function helper1 ($args, $named) {
+ $u = (isset($args[0])) ? $args[0] : 'undefined';
+ $t = (isset($args[1])) ? $args[1] : 'undefined';
+ return "<a href=\"{$u}\">{$t}</a>";
+}
+
+// Custom Helper Interface ... named arguments
+// Template: {{helper1 url=article.url text=article.text [ur"l]=article.extra}}
+function helper2 ($args, $named) {
+ $u = isset($named['url']) ? jsraw($named['url']) : 'undefined';
+ $t = isset($named['text']) ? jsraw($named['text']) : 'undefined';
+ $x = isset($named['ur"l']) ? $named['ur"l'] : 'undefined';
+ return "<a href=\"{$u}\">{$t}</a>({$x})";
+}
+
+// Block Custom Helper Interface ...
+// Template: {{helper3 articles}}
+function helper3 ($cx, $args, $named) {
+ return Array('test1', 'test2', 'test3');
+}
+
+// Block Custom Helper Interface ...
+// Template: {{helper3 val=values odd=enable_odd}}
+function helper4 ($cx, $args, $named) {
+ if (isset($named['val']) && is_array($cx)) {
+ $cx['helper4_value'] = $named['val'] % 2;
+ return $cx;
+ }
+ if (isset($named['odd'])) {
+ return Array(1,3,5,7,9);
+ }
+}
+
+// Handlebars.js Custom Helper Interface ...
+// Template: {{#myeach articles}}Article: ....{{/myeach}}
+function myeach ($list, $options) {
+ foreach ($list as $item) {
+ $ret .= $options['fn']($item);
+ }
+ return $ret;
+}
+
+// Simulate Javascript toString() behaviors
+function jsraw ($i) {
+ if ($i === true) {
+ return 'true';
+ }
+ if ($i === false) {
+ return 'false';
+ }
+ return $i;
+}
+
+?>
diff --git a/vendor/zordius/lightncandy/tests/handlebarsSpecTest.php b/vendor/zordius/lightncandy/tests/handlebarsSpecTest.php
new file mode 100644
index 00000000..5124b226
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/handlebarsSpecTest.php
@@ -0,0 +1,162 @@
+<?php
+
+require_once('src/lightncandy.php');
+
+$tmpdir = sys_get_temp_dir();
+
+class HandlebarsSpecTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider jsonSpecProvider
+ */
+ public function testSpecs($spec)
+ {
+ global $tmpdir;
+
+ //// Skip bad specs
+ // No expect in spec
+ if (!isset($spec['expected'])) {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , no expected result in spec, skip.");
+ }
+ // This spec is bad , lightncandy result as '} hello }' and same with mustache.js
+ if ($spec['template'] === '{{{{raw}}}} {{test}} {{{{/raw}}}}') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , bad spec, skip.");
+ }
+ // missing partial in this spec
+ if ($spec['it'] === 'rendering function partial in vm mode') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , bad spec, skip.");
+ }
+ // Helper depend on an external class, skip it now.
+ if ($spec['it'] === 'simple literals work') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , external class not found, skip.");
+ }
+ // partial not found: global_test
+ if ($spec['message'] === 'Partials can use globals or passed') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , partial not found, skip.");
+ }
+ // lambda not found in spec
+ if ($spec['it'] === "bug reported by @fat where lambdas weren't being properly resolved") {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , lambda not found, skip.");
+ }
+
+ //// Skip unsupported features
+ // can not get any hint of 'function' from handlebars-spec , maybe it is a conversion error.
+ if (($spec['description'] === 'basic context') && preg_match('/functions/', $spec['it'])) {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , undefined function in spec json, skip.");
+ }
+ if (preg_match('/(.+) with function argument/', $spec['it'])) {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , undefined function in spec json, skip.");
+ }
+ if ($spec['it'] === 'Functions are bound to the context in knownHelpers only mode') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , undefined function in spec json, skip.");
+ }
+ if ($spec['it'] === 'lambdas are resolved by blockHelperMissing, not handlebars proper') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , undefined function in spec json, skip.");
+ }
+ if ($spec['description'] === '#SafeString') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , undefined function in spec json, skip.");
+ }
+
+ // Do not support includeZero now
+ if (($spec['description'] === '#if') && preg_match('/includeZero=true/', $spec['template'])) {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , lightncandy do not support this now.");
+ }
+
+ // Do not support setting options.data now
+ if ($spec['it'] === 'data passed to helpers') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , lightncandy do not support this now.");
+ }
+
+ // Do not support buildin helper : lookup now
+ if ($spec['description'] == '#lookup') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , lightncandy do not support this now.");
+ }
+
+ // Lightncandy will not support old path style as foo/bar , now only support foo.bar .
+ if ($spec['it'] === 'literal paths') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , lightncandy do not support this now.");
+ }
+
+ // Do not support {{~{foo}~}} , use {{{~foo~}}}
+ if ($spec['template'] === ' {{~{foo}~}} ') {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , lightncandy do not support this now.");
+ }
+
+ // setup helpers
+ $helpers = Array();
+ if (isset($spec['helpers'])) {
+ foreach ($spec['helpers'] as $name => $func) {
+ if (!isset($func['php'])) {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , no PHP helper code provided for this case.");
+ }
+
+ // Wrong PHP helper interface in spec, skip.
+ preg_match('/function\s*\(.+?\)/', isset($func['javascript']) ? $func['javascript'] : '', $js_args);
+ preg_match('/function\s*\(.+?\)/', $func['php'], $php_args);
+ $jsn = isset($js_args[0]) ? substr_count($js_args[0], ',') : 0;
+ $phpn = isset($php_args[0]) ? substr_count($php_args[0], ',') : 0;
+ if ($jsn !== $phpn) {
+ $this->markTestIncomplete("Skip [{$spec['file']}#{$spec['description']}]#{$spec['no']} , PHP helper interface is wrong.");
+ }
+
+ $hname = "custom_helper_{$spec['no']}_$name";
+ $helpers[$name] = $hname;
+ eval(preg_replace('/function/', "function $hname", $func['php'], 1));
+ }
+
+ }
+
+ if (($spec['it'] === 'tokenizes hash arguments') || ($spec['it'] === 'tokenizes special @ identifiers')) {
+ $helpers['foo'] = function () {return 'ABC';};
+ }
+
+ $flag = LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_RUNTIMEPARTIAL | LightnCandy::FLAG_EXTHELPER | LightnCandy::FLAG_ERROR_SKIPPARTIAL | LightnCandy::FLAG_EXTHELPER;
+
+ foreach (Array($flag, $flag | LightnCandy::FLAG_STANDALONE) as $f) {
+ try {
+ $php = LightnCandy::compile($spec['template'], Array(
+ 'flags' => $f,
+ 'hbhelpers' => $helpers,
+ 'basedir' => $tmpdir,
+ 'partials' => isset($spec['partials']) ? $spec['partials'] : null,
+ ));
+ } catch (Exception $e) {
+ if (($spec['description'] === 'Tokenizer') && preg_match('/tokenizes inverse .+ as "OPEN_INVERSE.+CLOSE"/', $spec['it'])) {
+ continue;
+ }
+ print_r(LightnCandy::getContext());
+ $this->fail('Exception:' . $e->getMessage());
+ }
+ $renderer = LightnCandy::prepare($php);
+ if ($spec['description'] === 'Tokenizer') {
+ // no compile error means passed
+ continue;
+ }
+ $this->assertEquals($spec['expected'], $renderer($spec['data']), "[{$spec['file']}#{$spec['description']}]#{$spec['no']}:{$spec['it']} PHP CODE: $php");
+ }
+ }
+
+ public function jsonSpecProvider()
+ {
+ $ret = Array();
+
+ foreach (glob('specs/handlebars/spec/*.json') as $file) {
+ $i=0;
+ $json = json_decode(file_get_contents($file), true);
+ $ret = array_merge($ret, array_map(function ($d) use ($file, &$i) {
+ $d['file'] = $file;
+ $d['no'] = ++$i;
+ if (!isset($d['message'])) {
+ $d['message'] = null;
+ }
+ if (!isset($d['data'])) {
+ $d['data'] = null;
+ }
+ return Array($d);
+ }, $json));
+ }
+
+ return $ret;
+ }
+}
+?>
diff --git a/vendor/zordius/lightncandy/tests/helpers_for_test.php b/vendor/zordius/lightncandy/tests/helpers_for_test.php
new file mode 100644
index 00000000..93a1dbc7
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/helpers_for_test.php
@@ -0,0 +1,137 @@
+<?php
+
+// Classes for inputs or helpers
+class myClass {
+ function test() {
+ return 'testMethod OK!';
+ }
+
+ function helper2($arg) {
+ return "=$arg=";
+ }
+
+ function __call($method, $args) {
+ return "-- $method:" . print_r($args, true);
+ }
+}
+
+class foo {
+ public $prop = 'Yes!';
+
+ function bar() {
+ return 'OK!';
+ }
+}
+
+class twoDimensionIterator implements Iterator {
+ private $position = 0;
+ private $x = 0;
+ private $y = 0;
+ private $w = 0;
+ private $h = 0;
+
+ public function __construct($w, $h) {
+ $this->w = $w;
+ $this->h = $h;
+ $this->rewind();
+ }
+
+ function rewind() {
+ $this->position = 0;
+ $this->x = 0;
+ $this->y = 0;
+ }
+
+ function current() {
+ return $this->x * $this->y;
+ }
+
+ function key() {
+ return $this->x . 'x' . $this->y;
+ }
+
+ function next() {
+ ++$this->position;
+ $this->x = $this->position % $this->w;
+ $this->y = floor($this->position / $this->w);
+ }
+
+ function valid() {
+ return $this->position < $this->w * $this->h;
+ }
+}
+
+// Custom helpers
+function helper1($arg) {
+ return "-$arg-";
+}
+function alink($u, $t) {
+ return "<a href=\"$u\">$t</a>";
+}
+
+ function meetup_date_format() {
+ return "OKOK~1";
+}
+
+function meetup_date_format2() {
+ return "OKOK~2";
+}
+
+function meetup_date_format3 () {
+ return "OKOK~3";
+}
+
+function meetup_date_format4(){
+ return "OKOK~4";};
+
+
+function test_array ($input) {
+ return is_array($input[0]) ? 'IS_ARRAY' : 'NOT_ARRAY';
+}
+
+function test_join ($input) {
+ return join('.', $input[0]);
+}
+
+// Custom helpers for handlebars (should be used in hbhelpers)
+function myif ($conditional, $options) {
+ if ($conditional) {
+ return $options['fn']();
+ } else {
+ return $options['inverse']();
+ }
+}
+
+function mywith ($context, $options) {
+ return $options['fn']($context);
+}
+
+function myeach ($context, $options) {
+ $ret = '';
+ foreach ($context as $cx) {
+ $ret .= $options['fn']($cx);
+ }
+ return $ret;
+}
+
+function mylogic ($input, $yes, $no, $options) {
+ if ($input === true) {
+ return $options['fn']($yes);
+ } else {
+ return $options['inverse']($no);
+ }
+}
+
+function mydash ($a, $b) {
+ return "$a-$b";
+}
+
+function myjoin ($a, $b) {
+ return "$a$b";
+}
+
+function getroot ($options) {
+ return $options['data']['root'];
+}
+
+?>
diff --git a/vendor/zordius/lightncandy/tests/mustacheSpecTest.php b/vendor/zordius/lightncandy/tests/mustacheSpecTest.php
new file mode 100644
index 00000000..158f82cf
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/mustacheSpecTest.php
@@ -0,0 +1,53 @@
+<?php
+
+require_once('src/lightncandy.php');
+
+$tmpdir = sys_get_temp_dir();
+
+class MustacheSpecTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider jsonSpecProvider
+ */
+ public function testSpecs($spec)
+ {
+ global $tmpdir;
+
+ $flag = LightnCandy::FLAG_MUSTACHE | LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_RUNTIMEPARTIAL;
+
+ foreach (Array($flag, $flag | LightnCandy::FLAG_STANDALONE) as $f) {
+ $php = LightnCandy::compile($spec['template'], Array(
+ 'flags' => $f,
+ 'partials' => isset($spec['partials']) ? $spec['partials'] : null,
+ 'basedir' => $tmpdir,
+ ));
+ $renderer = LightnCandy::prepare($php);
+ $this->assertEquals($spec['expected'], $renderer($spec['data']), "[{$spec['file']}.{$spec['name']}]#{$spec['no']}:{$spec['desc']} PHP CODE: $php");
+ }
+ }
+
+ public function jsonSpecProvider()
+ {
+ $ret = Array();
+
+ foreach (glob('specs/mustache/specs/*.json') as $file) {
+ // Skip lambda extension
+ if (preg_match('/lambdas\\.json$/', $file)) {
+ continue;
+ }
+
+ $i=0;
+ $json = json_decode(file_get_contents($file), true);
+ $ret = array_merge($ret, array_map(function ($d) use ($file, &$i) {
+ $d['file'] = $file;
+ $d['no'] = ++$i;
+ return Array($d);
+ }, $json['tests']));
+ }
+
+ return $ret;
+ }
+}
+
+
+?>
diff --git a/vendor/zordius/lightncandy/tests/recursive.tmpl b/vendor/zordius/lightncandy/tests/recursive.tmpl
new file mode 100644
index 00000000..9e3290da
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/recursive.tmpl
@@ -0,0 +1 @@
+{{#if foo}}{{bar}} -> {{#with foo}}{{>recursive}}{{/with}}{{else}}END!{{/if}}
diff --git a/vendor/zordius/lightncandy/tests/regressionTest.php b/vendor/zordius/lightncandy/tests/regressionTest.php
new file mode 100644
index 00000000..bf591536
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/regressionTest.php
@@ -0,0 +1,736 @@
+<?php
+
+require_once('src/lightncandy.php');
+require_once('tests/helpers_for_test.php');
+
+$tmpdir = sys_get_temp_dir();
+
+class regressionTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider issueProvider
+ */
+ public function testIssues($issue)
+ {
+ global $tmpdir;
+
+ $php = LightnCandy::compile($issue['template'], isset($issue['options']) ? $issue['options'] : null);
+ $context = LightnCandy::getContext();
+ if (count($context['error'])) {
+ $this->fail('Compile failed due to:' . print_r($context['error'], true));
+ }
+ $renderer = LightnCandy::prepare($php);
+
+ $this->assertEquals($issue['expected'], $renderer($issue['data'], $issue['debug']), "PHP CODE:\n$php");
+ }
+
+ public function issueProvider()
+ {
+ $issues = Array(
+ Array(
+ 'id' => 39,
+ 'template' => '{{{tt}}}',
+ 'options' => null,
+ 'data' => Array('tt' => 'bla bla bla'),
+ 'expected' => 'bla bla bla'
+ ),
+
+ Array(
+ 'id' => 44,
+ 'template' => '<div class="terms-text"> {{render "artists-terms"}} </div>',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_ERROR_LOG | LightnCandy::FLAG_EXTHELPER,
+ 'helpers' => Array(
+ 'url',
+ 'render' => function($view,$data = array()) {
+ return 'OK!';
+ }
+ )
+ ),
+ 'data' => Array('tt' => 'bla bla bla'),
+ 'expected' => '<div class="terms-text"> OK! </div>'
+ ),
+
+ Array(
+ 'id' => 45,
+ 'template' => '{{{a.b.c}}}, {{a.b.bar}}, {{a.b.prop}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_ERROR_LOG | LightnCandy::FLAG_INSTANCE | LightnCandy::FLAG_HANDLEBARSJS,
+ ),
+ 'data' => Array('a' => Array('b' => new foo)),
+ 'expected' => ', OK!, Yes!'
+ ),
+
+ Array(
+ 'id' => 46,
+ 'template' => '{{{this.id}}}, {{a.id}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_THIS,
+ ),
+ 'data' => Array('id' => 'bla bla bla', 'a' => Array('id' => 'OK!')),
+ 'expected' => 'bla bla bla, OK!'
+ ),
+
+ Array(
+ 'id' => 49,
+ 'template' => '{{date_format}} 1, {{date_format2}} 2, {{date_format3}} 3, {{date_format4}} 4',
+ 'options' => Array(
+ 'helpers' => Array(
+ 'date_format' => 'meetup_date_format',
+ 'date_format2' => 'meetup_date_format2',
+ 'date_format3' => 'meetup_date_format3',
+ 'date_format4' => 'meetup_date_format4'
+ )
+ ),
+ 'data' => null,
+ 'expected' => 'OKOK~1 1, OKOK~2 2, OKOK~3 3, OKOK~4 4'
+ ),
+
+ Array(
+ 'id' => 52,
+ 'template' => '{{{test_array tmp}}} should be happy!',
+ 'options' => Array(
+ 'helpers' => Array(
+ 'test_array',
+ )
+ ),
+ 'data' => Array('tmp' => Array('A', 'B', 'C')),
+ 'expected' => 'IS_ARRAY should be happy!'
+ ),
+
+ Array(
+ 'id' => 62,
+ 'template' => '{{{test_join @root.foo.bar}}} should be happy!',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_ERROR_EXCEPTION,
+ 'helpers' => array('test_join')
+ ),
+ 'data' => Array('foo' => Array('A', 'B', 'bar' => Array('C', 'D'))),
+ 'expected' => 'C.D should be happy!',
+ ),
+
+ Array(
+ 'id' => 64,
+ 'template' => '{{#each foo}} Test! {{this}} {{/each}}{{> test1}} ! >>> {{>recursive}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_RUNTIMEPARTIAL,
+ 'basedir' => 'tests',
+ ),
+ 'data' => Array(
+ 'bar' => 1,
+ 'foo' => Array(
+ 'bar' => 3,
+ 'foo' => Array(
+ 'bar' => 5,
+ 'foo' => Array(
+ 'bar' => 7,
+ 'foo' => Array(
+ 'bar' => 11,
+ 'foo' => Array(
+ 'no foo here'
+ )
+ )
+ )
+ )
+ )
+ ),
+ 'expected' => " Test! 3 Test! [object Object] 123\n ! >>> 1 -> 3 -> 5 -> 7 -> 11 -> END!\n\n\n\n\n\n",
+ ),
+
+ Array(
+ 'id' => 66,
+ 'template' => '{{&foo}} , {{foo}}, {{{foo}}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS
+ ),
+ 'data' => Array('foo' => 'Test & " \' :)'),
+ 'expected' => 'Test & " \' :) , Test &amp; &quot; &#x27; :), Test & " \' :)',
+ ),
+
+ Array(
+ 'id' => 68,
+ 'template' => '{{#myeach foo}} Test! {{this}} {{/myeach}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS,
+ 'hbhelpers' => Array(
+ 'myeach' => function ($context, $options) {
+ $ret = '';
+ foreach ($context as $cx) {
+ $ret .= $options['fn']($cx);
+ }
+ return $ret;
+ }
+ )
+ ),
+ 'data' => Array('foo' => Array('A', 'B', 'bar' => Array('C', 'D', 'E'))),
+ 'expected' => ' Test! A Test! B Test! C,D,E ',
+ ),
+
+ Array(
+ 'id' => 81,
+ 'template' => '{{#with ../person}} {{^name}} Unknown {{/name}} {{/with}}?!',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_ERROR_EXCEPTION,
+ ),
+ 'data' => Array('parent?!' => Array('A', 'B', 'bar' => Array('C', 'D', 'E'))),
+ 'expected' => '?!'
+ ),
+
+ Array(
+ 'id' => 83,
+ 'template' => '{{> tests/test1}}',
+ 'options' => Array(
+ 'basedir' => '.',
+ ),
+ 'data' => null,
+ 'expected' => "123\n"
+ ),
+
+ Array(
+ 'id' => 85,
+ 'template' => '{{helper 1 foo bar="q"}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS,
+ 'hbhelpers' => Array(
+ 'helper' => function ($arg1, $arg2, $options) {
+ return "ARG1:$arg1, ARG2:$arg2, HASH:{$options['hash']['bar']}";
+ }
+ )
+ ),
+ 'data' => Array('foo' => 'BAR'),
+ 'expected' => 'ARG1:1, ARG2:BAR, HASH:q',
+ ),
+
+ Array(
+ 'id' => 88,
+ 'template' => '{{>test2}}',
+ 'options' => Array(
+ 'flags' => 0,
+ 'basedir' => 'tests',
+ ),
+ 'data' => null,
+ 'expected' => "a123\nb\n",
+ ),
+
+ Array(
+ 'id' => 89,
+ 'template' => '{{#with}}SHOW:{{.}} {{/with}}',
+ 'data' => Array('with' => Array(1, 3, 7), 'a' => Array(2, 4, 9)),
+ 'expected' => 'SHOW:1 SHOW:3 SHOW:7 ',
+ ),
+
+ Array(
+ 'id' => 90,
+ 'template' => '{{#items}}{{#value}}{{.}}{{/value}}{{/items}}',
+ 'data' => Array('items' => Array(Array('value'=>'123'))),
+ 'expected' => '123',
+ ),
+
+ Array(
+ 'id' => 109,
+ 'template' => '{{#if "OK"}}it\'s great!{{/if}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_NOESCAPE,
+ ),
+ 'data' => null,
+ 'expected' => 'it\'s great!',
+ ),
+
+ Array(
+ 'id' => 110,
+ 'template' => 'ABC{{#block "YES!"}}DEF{{foo}}GHI{{/block}}JKL',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_BESTPERFORMANCE,
+ 'hbhelpers' => Array(
+ 'block' => function ($name, $options) {
+ return "1-$name-2-" . $options['fn']() . '-3';
+ }
+ ),
+ ),
+ 'data' => Array('foo' => 'bar'),
+ 'expected' => 'ABC1-YES!-2-DEFbarGHI-3JKL',
+ ),
+
+ Array(
+ 'id' => 109,
+ 'template' => '{{foo}} {{> test}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_NOESCAPE,
+ 'partials' => Array('test' => '{{foo}}'),
+ ),
+ 'data' => Array('foo' => '<'),
+ 'expected' => '< <',
+ ),
+
+ Array(
+ 'id' => 114,
+ 'template' => '{{^myeach .}}OK:{{.}},{{else}}NOT GOOD{{/myeach}}',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_BESTPERFORMANCE,
+ 'hbhelpers' => Array(
+ 'myeach' => function ($context, $options) {
+ $ret = '';
+ foreach ($context as $cx) {
+ $ret .= $options['fn']($cx);
+ }
+ return $ret;
+ }
+ ),
+ ),
+ 'data' => Array(1, 'foo', 3, 'bar'),
+ 'expected' => 'NOT GOODNOT GOODNOT GOODNOT GOOD',
+ ),
+
+ Array(
+ 'template' => 'ABC{{#block "YES!"}}DEF{{foo}}GHI{{else}}NO~{{/block}}JKL',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_BESTPERFORMANCE,
+ 'hbhelpers' => Array(
+ 'block' => function ($name, $options) {
+ return "1-$name-2-" . $options['fn']() . '-3';
+ }
+ ),
+ ),
+ 'data' => Array('foo' => 'bar'),
+ 'expected' => 'ABC1-YES!-2-DEFbarGHI-3JKL',
+ ),
+
+ Array(
+ 'template' => '-{{getroot}}=',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_SPVARS,
+ 'hbhelpers' => Array('getroot'),
+ ),
+ 'data' => 'ROOT!',
+ 'expected' => '-ROOT!=',
+ ),
+
+ Array(
+ 'template' => 'A{{#each .}}-{{#each .}}={{.}},{{@key}},{{@index}},{{@../index}}~{{/each}}%{{/each}}B',
+ 'data' => Array(Array('a' => 'b'), Array('c' => 'd'), Array('e' => 'f')),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_PARENT | LightnCandy::FLAG_THIS | LightnCandy::FLAG_SPVARS,
+ ),
+ 'expected' => 'A-=b,a,0,0~%-=d,c,0,1~%-=f,e,0,2~%B',
+ ),
+
+ Array(
+ 'template' => 'ABC{{#block "YES!"}}TRUE{{else}}DEF{{foo}}GHI{{/block}}JKL',
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_BESTPERFORMANCE,
+ 'hbhelpers' => Array(
+ 'block' => function ($name, $options) {
+ return "1-$name-2-" . $options['inverse']() . '-3';
+ }
+ ),
+ ),
+ 'data' => Array('foo' => 'bar'),
+ 'expected' => 'ABC1-YES!-2-DEFbarGHI-3JKL',
+ ),
+
+ Array(
+ 'template' => '{{#each .}}{{..}}>{{/each}}',
+ 'data' => Array('a', 'b', 'c'),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS,
+ ),
+ 'expected' => 'a,b,c>a,b,c>a,b,c>',
+ ),
+
+ Array(
+ 'template' => '{{#each .}}->{{>tests/test3}}{{/each}}',
+ 'data' => Array('a', 'b', 'c'),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS,
+ 'basedir' => '.',
+ ),
+ 'expected' => "->New context:a\n->New context:b\n->New context:c\n",
+ ),
+
+ Array(
+ 'template' => '{{#each .}}->{{>tests/test3 ../foo}}{{/each}}',
+ 'data' => Array('a', 'foo' => Array('d', 'e', 'f')),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_RUNTIMEPARTIAL,
+ 'basedir' => '.',
+ ),
+ 'expected' => "->New context:d,e,f\n->New context:d,e,f\n",
+ ),
+
+ Array(
+ 'template' => '{{{"{{"}}}',
+ 'data' => null,
+ 'expected' => '{{',
+ ),
+
+ Array(
+ 'template' => '{{good_helper}}',
+ 'data' => null,
+ 'options' => Array(
+ 'helpers' => Array('good_helper' => 'foo::bar'),
+ ),
+ 'expected' => 'OK!',
+ ),
+
+ Array(
+ 'template' => '-{{.}}-',
+ 'options' => Array('flags' => LightnCandy::FLAG_THIS),
+ 'data' => 'abc',
+ 'expected' => '-abc-',
+ ),
+
+ Array(
+ 'template' => '-{{this}}-',
+ 'options' => Array('flags' => LightnCandy::FLAG_THIS),
+ 'data' => 123,
+ 'expected' => '-123-',
+ ),
+
+ Array(
+ 'template' => '{{#if .}}YES{{else}}NO{{/if}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_ELSE),
+ 'data' => true,
+ 'expected' => 'YES',
+ ),
+
+ Array(
+ 'template' => '{{foo}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_RENDER_DEBUG),
+ 'data' => Array('foo' => 'OK'),
+ 'expected' => 'OK',
+ ),
+
+ Array(
+ 'template' => '{{foo}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_RENDER_DEBUG),
+ 'debug' => LCRun3::DEBUG_TAGS_ANSI,
+ 'data' => Array('foo' => 'OK'),
+ 'expected' => pack('H*', '1b5b303b33326d7b7b5b666f6f5d7d7d1b5b306d'),
+ ),
+
+ Array(
+ 'template' => '{{foo}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_RENDER_DEBUG),
+ 'debug' => LCRun3::DEBUG_TAGS_HTML,
+ 'data' => null,
+ 'expected' => '<!--MISSED((-->{{[foo]}}<!--))-->',
+ ),
+
+ Array(
+ 'template' => '{{#foo}}OK{{/foo}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_RENDER_DEBUG),
+ 'debug' => LCRun3::DEBUG_TAGS_HTML,
+ 'data' => null,
+ 'expected' => '<!--MISSED((-->{{#[foo]}}<!--))--><!--SKIPPED--><!--MISSED((-->{{/[foo]}}<!--))-->',
+ ),
+
+ Array(
+ 'template' => '{{#foo}}OK{{/foo}}',
+ 'options' => Array('flags' => LightnCandy::FLAG_RENDER_DEBUG),
+ 'debug' => LCRun3::DEBUG_TAGS_ANSI,
+ 'data' => null,
+ 'expected' => pack('H*', '1b5b303b33316d7b7b235b666f6f5d7d7d1b5b306d1b5b303b33336d534b49505045441b5b306d1b5b303b33316d7b7b2f5b666f6f5d7d7d1b5b306d'),
+ ),
+
+ Array(
+ 'template' => '{{#myif foo}}YES{{else}}NO{{/myif}}',
+ 'data' => null,
+ 'options' => Array(
+ 'hbhelpers' => Array('myif'),
+ ),
+ 'expected' => 'NO',
+ ),
+
+ Array(
+ 'template' => '{{#myif foo}}YES{{else}}NO{{/myif}}',
+ 'data' => Array('foo' => 1),
+ 'options' => Array(
+ 'hbhelpers' => Array('myif'),
+ ),
+ 'expected' => 'YES',
+ ),
+
+ Array(
+ 'template' => '{{#mylogic 0 foo bar}}YES:{{.}}{{else}}NO:{{.}}{{/mylogic}}',
+ 'data' => Array('foo' => 'FOO', 'bar' => 'BAR'),
+ 'options' => Array(
+ 'hbhelpers' => Array('mylogic'),
+ ),
+ 'expected' => 'NO:BAR',
+ ),
+
+ Array(
+ 'template' => '{{#mylogic true foo bar}}YES:{{.}}{{else}}NO:{{.}}{{/mylogic}}',
+ 'data' => Array('foo' => 'FOO', 'bar' => 'BAR'),
+ 'options' => Array(
+ 'hbhelpers' => Array('mylogic'),
+ ),
+ 'expected' => 'YES:FOO',
+ ),
+
+ Array(
+ 'template' => '{{#mywith foo}}YA: {{name}}{{/mywith}}',
+ 'data' => Array('name' => 'OK?', 'foo' => Array('name' => 'OK!')),
+ 'options' => Array(
+ 'hbhelpers' => Array('mywith'),
+ ),
+ 'expected' => 'YA: OK!',
+ ),
+
+ Array(
+ 'template' => '{{mydash \'abc\' "dev"}}',
+ 'data' => Array('a' => 'a', 'b' => 'b', 'c' => Array('c' => 'c'), 'd' => 'd', 'e' => 'e'),
+ 'options' => Array(
+ 'hbhelpers' => Array('mydash'),
+ ),
+ 'expected' => 'abc-dev',
+ ),
+
+ Array(
+ 'template' => '{{mydash \'a b c\' "d e f"}}',
+ 'data' => Array('a' => 'a', 'b' => 'b', 'c' => Array('c' => 'c'), 'd' => 'd', 'e' => 'e'),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_ADVARNAME,
+ 'hbhelpers' => Array('mydash'),
+ ),
+ 'expected' => 'a b c-d e f',
+ ),
+
+ Array(
+ 'template' => '{{mydash "abc" (test_array 1)}}',
+ 'data' => Array('a' => 'a', 'b' => 'b', 'c' => Array('c' => 'c'), 'd' => 'd', 'e' => 'e'),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_ADVARNAME,
+ 'hbhelpers' => Array('mydash'),
+ 'helpers' => Array('test_array'),
+ ),
+ 'expected' => 'abc-NOT_ARRAY',
+ ),
+
+ Array(
+ 'template' => '{{mydash "abc" (myjoin a b)}}',
+ 'data' => Array('a' => 'a', 'b' => 'b', 'c' => Array('c' => 'c'), 'd' => 'd', 'e' => 'e'),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_ADVARNAME,
+ 'hbhelpers' => Array('mydash', 'myjoin'),
+ ),
+ 'expected' => 'abc-ab',
+ ),
+
+ Array(
+ 'template' => '{{#with people}}Yes , {{name}}{{else}}No, {{name}}{{/with}}',
+ 'data' => Array('people' => Array('name' => 'Peter'), 'name' => 'NoOne'),
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH),
+ 'expected' => 'Yes , Peter',
+ ),
+
+ Array(
+ 'template' => '{{#with people}}Yes , {{name}}{{else}}No, {{name}}{{/with}}',
+ 'data' => Array('name' => 'NoOne'),
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH),
+ 'expected' => 'No, NoOne',
+ ),
+
+ Array(
+ 'template' => <<<VAREND
+<ul>
+ <li>1. {{helper1 name}}</li>
+ <li>2. {{helper1 value}}</li>
+ <li>3. {{myClass::helper2 name}}</li>
+ <li>4. {{myClass::helper2 value}}</li>
+ <li>5. {{he name}}</li>
+ <li>6. {{he value}}</li>
+ <li>7. {{h2 name}}</li>
+ <li>8. {{h2 value}}</li>
+ <li>9. {{link name}}</li>
+ <li>10. {{link value}}</li>
+ <li>11. {{alink url text}}</li>
+ <li>12. {{{alink url text}}}</li>
+</ul>
+VAREND
+ ,
+ 'data' => Array('name' => 'John', 'value' => 10000, 'url' => 'http://yahoo.com', 'text' => 'You&Me!'),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_ERROR_LOG | LightnCandy::FLAG_HANDLEBARSJS,
+ 'helpers' => Array(
+ 'helper1',
+ 'myClass::helper2',
+ 'he' => 'helper1',
+ 'h2' => 'myClass::helper2',
+ 'link' => function ($arg) {
+ return "<a href=\"{$arg}\">click here</a>";
+ },
+ 'alink',
+ )
+ ),
+ 'expected' => <<<VAREND
+<ul>
+ <li>1. -Array-</li>
+ <li>2. -Array-</li>
+ <li>3. =Array=</li>
+ <li>4. =Array=</li>
+ <li>5. -Array-</li>
+ <li>6. -Array-</li>
+ <li>7. =Array=</li>
+ <li>8. =Array=</li>
+ <li>9. &lt;a href=&quot;Array&quot;&gt;click here&lt;/a&gt;</li>
+ <li>10. &lt;a href=&quot;Array&quot;&gt;click here&lt;/a&gt;</li>
+ <li>11. &lt;a href=&quot;Array&quot;&gt;Array&lt;/a&gt;</li>
+ <li>12. <a href="Array">Array</a></li>
+</ul>
+VAREND
+ ),
+
+ Array(
+ 'template' => '{{test.test}} == {{test.test3}}',
+ 'data' => Array('test' => new myClass()),
+ 'options' => Array('flags' => LightnCandy::FLAG_INSTANCE),
+ 'expected' => "testMethod OK! == -- test3:Array\n(\n)\n",
+ ),
+
+ Array(
+ 'template' => '{{test.test}} == {{test.bar}}',
+ 'data' => Array('test' => new foo()),
+ 'options' => Array('flags' => LightnCandy::FLAG_INSTANCE),
+ 'expected' => ' == OK!',
+ ),
+
+ Array(
+ 'template' => '{{#each foo}}{{@key}}: {{.}},{{/each}}',
+ 'data' => Array('foo' => Array(1,'a'=>'b',5)),
+ 'expected' => ': 1,: b,: 5,',
+ ),
+
+ Array(
+ 'template' => '{{#each foo}}{{@key}}: {{.}},{{/each}}',
+ 'data' => Array('foo' => Array(1,'a'=>'b',5)),
+ 'options' => Array('flags' => LightnCandy::FLAG_SPVARS),
+ 'expected' => '0: 1,a: b,1: 5,',
+ ),
+
+ Array(
+ 'template' => '{{#each foo}}{{@key}}: {{.}},{{/each}}',
+ 'data' => Array('foo' => new twoDimensionIterator(2, 3)),
+ 'options' => Array('flags' => LightnCandy::FLAG_SPVARS),
+ 'expected' => '0x0: 0,1x0: 0,0x1: 0,1x1: 1,0x2: 0,1x2: 2,',
+ ),
+
+ Array(
+ 'template' => " {{#foo}}\n {{name}}\n{{/foo}}\n ",
+ 'data' => Array('foo' => Array(Array('name' => 'A'),Array('name' => 'd'),Array('name' => 'E'))),
+ 'options' => Array('flags' => LightnCandy::FLAG_MUSTACHESP),
+ 'expected' => " A\n d\n E\n ",
+ ),
+
+ Array(
+ 'template' => "{{bar}}\n {{#foo}}\n {{name}}\n{{/foo}}\n ",
+ 'data' => Array('bar' => 'OK', 'foo' => Array(Array('name' => 'A'),Array('name' => 'd'),Array('name' => 'E'))),
+ 'options' => Array('flags' => LightnCandy::FLAG_MUSTACHESP),
+ 'expected' => "OK\n A\n d\n E\n ",
+ ),
+
+ Array(
+ 'template' => " {{#if foo}}\nYES\n{{else}}\nNO\n{{/if}}\n",
+ 'data' => null,
+ 'options' => Array('flags' => LightnCandy::FLAG_MUSTACHESP | LightnCandy::FLAG_ELSE),
+ 'expected' => "NO\n",
+ ),
+
+ Array(
+ 'template' => " {{#each foo}}\n{{@key}}: {{.}}\n{{/each}}\nDONE",
+ 'data' => Array('foo' => Array('a' => 'A', 'b' => 'BOY!')),
+ 'options' => Array('flags' => LightnCandy::FLAG_SPVARS | LightnCandy::FLAG_MUSTACHESP),
+ 'expected' => "a: A\nb: BOY!\nDONE",
+ ),
+
+ Array(
+ 'template' => "{{>test1}}\n {{>test1}}\nDONE\n",
+ 'data' => null,
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_MUSTACHESP | LightnCandy::FLAG_MUSTACHEPAIN,
+ 'partials' => Array('test1' => "1:A\n 2:B\n 3:C\n 4:D\n5:E\n"),
+ ),
+ 'expected' => "1:A\n 2:B\n 3:C\n 4:D\n5:E\n 1:A\n 2:B\n 3:C\n 4:D\n 5:E\nDONE\n",
+ ),
+
+ Array(
+ 'template' => "{{>test1}}\n {{>test1}}\nDONE\n",
+ 'data' => null,
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_MUSTACHESP,
+ 'partials' => Array('test1' => "1:A\n 2:B\n 3:C\n 4:D\n5:E\n"),
+ ),
+ 'expected' => "1:A\n 2:B\n 3:C\n 4:D\n5:E\n1:A\n 2:B\n 3:C\n 4:D\n5:E\nDONE\n",
+ ),
+
+ Array(
+ 'template' => "{{>test1}}\n {{>test1}}\nDONE\n",
+ 'data' => null,
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_MUSTACHESP | LightnCandy::FLAG_RUNTIMEPARTIAL,
+ 'partials' => Array('test1' => "1:A\n 2:B\n 3:C\n 4:D\n5:E\n"),
+ ),
+ 'expected' => "1:A\n 2:B\n 3:C\n 4:D\n5:E\n1:A\n 2:B\n 3:C\n 4:D\n5:E\nDONE\n",
+ ),
+
+ Array(
+ 'template' => "ST:\n{{#foo}}\n {{>test1}}\n{{/foo}}\nOK\n",
+ 'data' => Array('foo' => Array(1, 2)),
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_MUSTACHESP | LightnCandy::FLAG_MUSTACHEPAIN | LightnCandy::FLAG_HANDLEBARSJS,
+ 'partials' => Array('test1' => "1:A\n 2:B({{@index}})\n"),
+ ),
+ 'expected' => "ST:\n 1:A\n 2:B(0)\n 1:A\n 2:B(1)\nOK\n",
+ ),
+
+ Array(
+ 'template' => "A\n {{#if 1}} \n\na\n{{#with 2}}\n123\n\n{{/with}}\n{{/if}} \n \n\n456",
+ 'data' => null,
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH | LightnCandy::FLAG_MUSTACHESP),
+ 'expected' => "A\n\na\n123\n\n \n\n456",
+ ),
+
+ Array(
+ 'template' => "\n{{#with 1}}\n\n{{#with 1}}\nb\n\n{{/with}}\n{{/with}}\nC",
+ 'data' => null,
+ 'options' => Array('flags' => LightnCandy::FLAG_WITH | LightnCandy::FLAG_MUSTACHESP),
+ 'expected' => "\n\nb\n\nC",
+ ),
+
+ Array(
+ 'template' => ">{{helper1 \"===\"}}<",
+ 'data' => null,
+ 'options' => Array(
+ 'flags' => LightnCandy::FLAG_HANDLEBARSJS,
+ 'hbhelpers' => Array(
+ 'helper1',
+ )
+ ),
+ 'expected' => ">-===-<",
+ ),
+
+ Array(
+ 'template' => "{{foo}}",
+ 'data' => Array('foo' => 'A&B " \''),
+ 'options' => Array('flags' => LightnCandy::FLAG_NOESCAPE),
+ 'expected' => "A&B \" '",
+ ),
+
+ Array(
+ 'template' => "{{foo}}",
+ 'data' => Array('foo' => 'A&B " \''),
+ 'options' => null,
+ 'expected' => "A&amp;B &quot; &#039;",
+ ),
+ );
+
+ return array_map(function($i) {
+ if (!isset($i['debug'])) {
+ $i['debug'] = 0;
+ }
+ return Array($i);
+ }, $issues);
+ }
+}
+
+?>
diff --git a/vendor/zordius/lightncandy/tests/test1.tmpl b/vendor/zordius/lightncandy/tests/test1.tmpl
new file mode 100644
index 00000000..190a1803
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/test1.tmpl
@@ -0,0 +1 @@
+123
diff --git a/vendor/zordius/lightncandy/tests/test2.tmpl b/vendor/zordius/lightncandy/tests/test2.tmpl
new file mode 100644
index 00000000..df980f7e
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/test2.tmpl
@@ -0,0 +1 @@
+a{{> test1}}b
diff --git a/vendor/zordius/lightncandy/tests/test3.tmpl b/vendor/zordius/lightncandy/tests/test3.tmpl
new file mode 100644
index 00000000..0b4e6bb9
--- /dev/null
+++ b/vendor/zordius/lightncandy/tests/test3.tmpl
@@ -0,0 +1 @@
+New context:{{.}}