public function exists($name)
{
if ($this->loader instanceof \Twig_ExistsLoaderInterface) {
return $this->loader->exists($name);
} else {
try {
$this->loader->getSource($name);
return true;
} catch (\Twig_Error_Loader $e) {
return false;
}
}
}
public function testNonExistsWithBaseLoader() { $mockLoader = $this->getMock('Twig_LoaderInterface'); $mockLoader->expects($this->once())->method('getSource')->with($this->equalTo('foo'))->will($this->throwException(new \Twig_Error_Loader("File not found"))); $mockLoader->expects($this->never())->method('exists'); $twitalLoader = new TwitalLoader($mockLoader, null, false); $this->assertFalse($twitalLoader->exists('foo')); }