public function testGlobalExists() { $extension = new TestExtension1(); $this->getWiser()->getEnvironment()->addExtension($extension); $view = new View(__DIR__ . '/Fixture/variables/global.html.php'); $view->setWiser($this->getWiser()); $output = $view->render(); $this->assertEquals('global', $output); }
/** * @param $file * * @return View */ public function getView($file) { $templates = $this->findTemplates($file); $fileName = array_keys(iterator_to_array($templates)); $fileName = array_shift($fileName); if (!isset($this->views[$fileName])) { $view = new View($fileName); $view->setWiser($this); $this->views[$fileName] = $view; } return $this->views[$fileName]; }
public function testBasicCacheView() { $view = new View(__DIR__ . '/../Fixture/basic_template.html.php'); $event = new GetViewEvent($view); $path = __DIR__ . '/../Fixture/cache_dir/'; $cache = new Cache(array('cache_path' => $path, 'cache_expiration' => 'P1D')); // simulate events $cache->onRenderStart($event); $output = $view->render(); $cache->onRenderFinish($view, $output); $cache->onRenderStart($event); $fileName = $view->getFileName(); $expected = $path . $view->getHash() . '.html'; $this->assertEquals($expected, $fileName); }
private function getViewCacheFile(View $view) { $hash = $view->getHash(); return $this->cachePath . $hash . "." . $this->cacheExtension; }