예제 #1
0
 /**
  * @covers ::render
  */
 public function testRenderWithData()
 {
     $data = ['foo' => 'bar'];
     $this->parserMock->shouldReceive('parse')->with('file', $data)->andReturn('')->once();
     $this->managerMock->shouldReceive('getData')->once()->andReturn([]);
     $this->view->render($data);
 }
예제 #2
0
 /**
  * Attempts to find and load the given view
  *
  * @param string    $view
  * @param array     $data
  * @param null|bool $filter
  *
  * @return View
  *
  * @throws Exception\ViewNotFound If the given view cannot be found
  * @throws \DomainException       If a parser for the view cannot be found
  */
 public function forge($view, array $data = null, $filter = null)
 {
     if (!($file = $this->findView($view))) {
         throw new Exception\ViewNotFound('Could not locate view: ' . $view);
     }
     if ($filter === null) {
         $filter = $this->autoFilter;
     }
     $extension = pathinfo($file, PATHINFO_EXTENSION);
     if (!isset($this->parsers[$extension])) {
         throw new \DomainException('Could not find parser for extension: ' . $extension);
     }
     $parser = $this->parsers[$extension];
     $view = new View($this, $parser, $file, $filter);
     if ($data) {
         $view->set($data);
     }
     return $view;
 }