Esempio n. 1
0
 public function it_delegates_renderer_to_report($serviceRegistryInterface, ReportInterface $subject, RendererInterface $renderer, Data $data)
 {
     $subject->getRenderer()->willReturn('default_renderer');
     $subject->getRendererConfiguration()->willReturn(array());
     $serviceRegistryInterface->get('default_renderer')->willReturn($renderer);
     $renderer->render($subject, $data)->shouldBeCalled();
     $this->render($subject, $data);
 }
Esempio n. 2
0
 function it_renders_data_with_given_configuration(ReportInterface $report, Data $reportData, $templating)
 {
     $reportData->getData()->willReturn(array('month1' => '50', 'month2' => '40'));
     $renderData = array('report' => $report, 'values' => array('month1' => '50', 'month2' => '40'), 'labels' => array('month1', 'month2'));
     $report->getRendererConfiguration()->willReturn(array('template' => 'SyliusReportBundle:Chart:default.html.twig'));
     $templating->render('SyliusReportBundle:Chart:default.html.twig', array('data' => $renderData, 'configuration' => array('template' => 'SyliusReportBundle:Chart:default.html.twig')))->willReturn('<div>Chart Report</div>');
     $this->render($report, $reportData)->shouldReturn('<div>Chart Report</div>');
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function render(ReportInterface $report, Data $data)
 {
     if (null !== $data->getData()) {
         $data = array('report' => $report, 'values' => $data->getData(), 'labels' => $data->getLabels(), 'fields' => array_keys($data->getData()));
         $rendererConfiguration = $report->getRendererConfiguration();
         return $this->templating->render($rendererConfiguration["template"], array('data' => $data, 'configuration' => $rendererConfiguration));
     }
     return $this->templating->render("SyliusReportBundle::noDataTemplate.html.twig", array('report' => $report));
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function render(ReportInterface $report, Data $data)
 {
     if (null !== $data->getData()) {
         $rendererData = ['report' => $report, 'values' => $data->getData(), 'labels' => array_keys($data->getData())];
         $rendererConfiguration = $report->getRendererConfiguration();
         return $this->templating->render($rendererConfiguration['template'], ['data' => $rendererData, 'configuration' => $rendererConfiguration]);
     }
     return $this->templating->render('SyliusReportBundle::noDataTemplate.html.twig', ['report' => $report]);
 }
Esempio n. 5
0
 function it_renders_data_with_given_configuration(ReportInterface $report, Response $response, Data $reportData, $templating)
 {
     $reportData->getLabels()->willReturn(array('month', 'user_total'));
     $reportData->getData()->willReturn(array('month1' => '50', 'month2' => '40'));
     $renderData = array('report' => $report, 'values' => array('month1' => '50', 'month2' => '40'), 'labels' => array('month', 'user_total'), 'fields' => array('month1', 'month2'));
     $report->getRendererConfiguration()->willReturn(array('template' => 'SyliusReportBundle:Table:default.html.twig'));
     $templating->renderResponse('SyliusReportBundle:Table:default.html.twig', array('data' => $renderData, 'configuration' => array('template' => 'SyliusReportBundle:Table:default.html.twig')))->willReturn($response);
     $this->render($report, $reportData)->shouldReturn($response);
 }
Esempio n. 6
0
 function it_renders_data_with_given_configuration(ReportInterface $report, Data $reportData, $templating)
 {
     $reportData->getLabels()->willReturn(['month', 'user_total']);
     $reportData->getData()->willReturn(['month1' => '50', 'month2' => '40']);
     $renderData = ['report' => $report, 'values' => ['month1' => '50', 'month2' => '40'], 'labels' => ['month', 'user_total'], 'fields' => ['month1', 'month2']];
     $report->getRendererConfiguration()->willReturn(['template' => 'SyliusReportBundle:Table:default.html.twig']);
     $templating->render('SyliusReportBundle:Table:default.html.twig', ['data' => $renderData, 'configuration' => ['template' => 'SyliusReportBundle:Table:default.html.twig']])->willReturn('<div>Table Report</div>');
     $this->render($report, $reportData)->shouldReturn('<div>Table Report</div>');
 }
 function it_adds_configuration_fields_in_pre_set_data($factory, ReportInterface $report, FormEvent $event, Form $form, Form $field)
 {
     $report->getRenderer()->willReturn('test_renderer');
     $report->getRendererConfiguration()->willReturn([]);
     $event->getData()->willReturn($report);
     $event->getForm()->willReturn($form);
     $factory->createNamed('rendererConfiguration', 'sylius_renderer_test_type', Argument::cetera())->willReturn($field);
     $form->add($field)->shouldBeCalled();
     $this->preSetData($event);
 }