public function testTransformAssets()
 {
     $loader = $this->getMockBuilder('\\Twig_LoaderInterface')->disableOriginalConstructor()->getMock();
     $report = $this->getMockBuilder('\\RAM\\BaseReport')->setMethods(['getName'])->disableOriginalConstructor()->getMockForAbstractClass();
     $extensionManager = new RenderEngineExtensionManager();
     $router = $this->getMockBuilder('\\Twig_Extension')->disableOriginalConstructor()->setMethods(['getName', 'buildDomHeader', 'getUrl', 'isSafeUrl', 'getHttpsWrappedUrl'])->getMock();
     $router->expects($this->any())->method('getName')->willReturn('report_routing');
     $router->expects($this->any())->method('isSafeUrl')->willReturn(false);
     $extensionManager->addExtension($router);
     $engine = new RenderEngine($loader, $report, [], $extensionManager);
     $testDoc = null;
     try {
         $engine->transformAssetPaths($testDoc);
     } catch (\Exception $ex) {
         $this->assertInstanceOf('RAM\\Exception\\ContentNotFoundException', $ex);
     }
     $testDoc = '<html>
     <img src="/bla" />
     <link href="/blabla" rel="stylesheet" />
      <script src="/blablabla" type="text/javascript"></script>
     </html>';
     $engine->transformAssetPaths($testDoc);
 }
Exemple #2
0
 /**
  * Run the report and return the response.
  *
  * @return string
  */
 public final function run()
 {
     $preEvent = new FilterReportEvent($this);
     $this->dispatcher->dispatch(ReportEvents::REPORT_PRE_RENDER, $preEvent);
     try {
         $response = $this->render();
     } catch (\Exception $ex) {
         $this->log($ex);
         throw new RenderReportException('There was an error rendering the report', $ex);
     }
     $this->response = $this->renderEngine->transformAssetPaths($response);
     $postEvent = new FilterReportEvent($this);
     $this->dispatcher->dispatch(ReportEvents::REPORT_POST_RENDER, $postEvent);
     return $this->response;
 }