Example #1
0
 public function createView()
 {
     $view = parent::createView();
     $view->setTemplate($this->configuration->getTemplate('EnhavoAppBundle:Viewer:app.html.twig'));
     $view->setTemplateData(array_merge($view->getTemplateData(), ['blocks' => $this->getBlocks(), 'actions' => $this->getActions(), 'title' => $this->getTitle()]));
     return $view;
 }
Example #2
0
 function testCreateView()
 {
     $containerMock = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock();
     $containerMock->method('getParameter')->will($this->returnCallback(function ($id) {
         if ($id == 'enhavo_app.stylesheets') {
             return ['path/to/style.css', 'path/to/admin.css'];
         }
         if ($id == 'enhavo_app.javascripts') {
             return ['path/to/main.js', 'path/to/basic.js'];
         }
         return [];
     }));
     $optionAccessorMock = $this->getMockBuilder('Enhavo\\Bundle\\AppBundle\\Viewer\\OptionAccessor')->getMock();
     $optionAccessorMock->method('get')->will($this->returnCallback(function ($id) {
         if ($id == 'stylesheets') {
             return ['path/to/style.css', 'path/to/admin.css'];
         }
         if ($id == 'javascripts') {
             return ['path/to/main.js', 'path/to/basic.js'];
         }
         return [];
     }));
     $configurationMock = $this->getMockBuilder('Enhavo\\Bundle\\AppBundle\\Controller\\RequestConfigurationInterface')->getMock();
     $configurationMock->method('getTemplate')->willReturn('template');
     $viewer = new BaseViewer();
     $viewer->setContainer($containerMock);
     $viewer->setOptionAccessor($optionAccessorMock);
     $viewer->setConfiguration($configurationMock);
     $view = $viewer->createView();
     $this->assertInstanceOf('FOS\\RestBundle\\View\\View', $view);
     $data = $view->getTemplateData();
     $this->assertArrayHasKey('javascripts', $data);
     $this->assertArrayHasKey('stylesheets', $data);
 }