function testCheckCallbackFailsOnException() { $h = ['nup' => function () { }]; $r = ['nup' => ['check' => function ($handler, $node, $chainPos) { throw new \Tempe\Exception\Check("NUP!", $node->line); }]]; $parser = new Parser(new Basic($h, $r)); $this->setExpectedException('Tempe\\Exception\\Check', "NUP!"); $parser->parse('{= nup }'); }
function testHandlerUnknown() { $lang = new \Tempe\Lang\Basic([]); $parser = new \Tempe\Parser(); $renderer = new \Tempe\Renderer($lang); $this->setExpectedException("Tempe\\Exception\\Render", "Handler 'nope' not found at line 1"); $renderer->renderTree($parser->parse("{=nope}")); }
function testRenderCheck() { $tpl = "{= oi }"; $lang = new \Tempe\Lang\Basic(['oi' => function () { return 'oi'; }], ['oi' => ['argc' => 1]]); $parser = new Parser(); $tree = $parser->parse($tpl); $renderer = new Renderer($lang, null, !!'check'); $this->setExpectedException('Tempe\\Exception\\Check'); $renderer->renderTree($tree); }