private function getUsedTemplates(\Twig_Profiler_Profile $profile) { $templates = array(); foreach ($profile as $p) { if ($p->isTemplate()) { try { $templates[] = array('template' => $p->getTemplate(), 'fullPath' => $this->filesystemLoader->getCacheKey($p->getTemplate())); } catch (\Exception $e) { } } $templates = array_merge($templates, $this->getUsedTemplates($p)); } return $templates; }
/** * @expectedException \Twig_Error_Loader */ public function testTwigErrorIfLocatorReturnsFalse() { $parser = $this->getMock('Symfony\\Component\\Templating\\TemplateNameParserInterface'); $parser->expects($this->once())->method('parse')->with('name.format.engine')->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))); $locator = $this->getMock('Symfony\\Component\\Config\\FileLocatorInterface'); $locator->expects($this->once())->method('locate')->will($this->returnValue(false)); $loader = new FilesystemLoader($locator, $parser); $loader->getCacheKey('name.format.engine'); }
public function testTwigErrorIfLocatorReturnsFalse() { $this->setExpectedException('Twig_Error_Loader'); $this->locator->expects($this->once())->method('locate')->will($this->returnValue(false)); $this->loader->getCacheKey('name.format.engine'); }