public function testSetEngine()
 {
     $view = new View();
     $engine = 'bar';
     $view->setEngine($engine);
     $this->assertEquals($engine, $view->getEngine());
 }
 /**
  * Render the view data with the given template
  *
  * @param View $view
  * @param string $format
  *
  * @return string
  */
 public function renderTemplate(View $view, $format)
 {
     $data = $view->getData();
     if (null === $data) {
         $data = array();
     }
     if (!is_array($data)) {
         throw new \RuntimeException(sprintf('data must be an array if you allow a templating-aware format (%s).', $format));
     }
     if (isset($data['form']) && $data['form'] instanceof FormInterface) {
         $data['form'] = $data['form']->createView();
     }
     $template = $view->getTemplate();
     if ($template instanceof TemplateReference) {
         if (null === $template->get('format')) {
             $template->set('format', $format);
         }
         if (null === $template->get('engine')) {
             $engine = $view->getEngine() ?: $this->defaultEngine;
             $template->set('engine', $engine);
         }
     }
     return $this->getTemplating()->render($template, $data);
 }