示例#1
0
 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);
 }
示例#2
0
 /**
  * @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];
 }
示例#3
0
 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);
 }
示例#4
0
 private function getViewCacheFile(View $view)
 {
     $hash = $view->getHash();
     return $this->cachePath . $hash . "." . $this->cacheExtension;
 }