/** * @param string $setName * @param string $source * @param array $variables * @test * @dataProvider getNodeCountProfilingData */ public function parsingCreatesExpectedOrLowerNodeCount($setName, $source, array $variables) { $parser = new TemplateParser(); $closure = function () use($parser, $source) { $parser->parse($source); }; $results = $this->profileClosure($closure, array('/.+Node::__construct$/')); $createdNodes = 0; foreach ($results as $counterData) { $createdNodes += $counterData['ct']; } $this->assertLessThanOrEqualToMinimum($setName, $createdNodes); }
/** * @param string $templateIdentifier * @param \Closure $templateSourceClosure Closure which returns the template source if needed * @return ParsedTemplateInterface */ protected function getOrParseAndStoreTemplate($templateIdentifier, $templateSourceClosure) { if ($this->templateCompiler->has($templateIdentifier)) { $parsedTemplate = $this->templateCompiler->get($templateIdentifier); } else { $parsedTemplate = $this->templateParser->parse($templateSourceClosure($this, $this->templatePaths)); if ($parsedTemplate->isCompilable()) { $this->templateCompiler->store($templateIdentifier, $parsedTemplate); } } return $parsedTemplate; }
/** * @test * @expectedException \TYPO3Fluid\Fluid\Core\Parser\Exception */ public function parseThrowsExceptionWhenStringArgumentMissing() { $templateParser = new TemplateParser(); $templateParser->parse(123); }
/** * Inject the Template Parser * * @param TemplateParser $templateParser The template parser * @return void */ public function setTemplateParser(TemplateParser $templateParser) { $this->templateParser = $templateParser; $this->templateParser->setRenderingContext($this); }