1 | <?php |
||||||
2 | |||||||
3 | namespace spec\Odiseo\SyliusReportPlugin\Renderer; |
||||||
4 | |||||||
5 | use Odiseo\SyliusReportPlugin\DataFetcher\Data; |
||||||
6 | use Odiseo\SyliusReportPlugin\Form\Type\Renderer\TableConfigurationType; |
||||||
7 | use Odiseo\SyliusReportPlugin\Model\ReportInterface; |
||||||
8 | use Odiseo\SyliusReportPlugin\Renderer\RendererInterface; |
||||||
9 | use Odiseo\SyliusReportPlugin\Renderer\TableRenderer; |
||||||
10 | use PhpSpec\ObjectBehavior; |
||||||
11 | use Symfony\Component\Templating\EngineInterface; |
||||||
12 | use Twig\Environment; |
||||||
13 | |||||||
14 | /** |
||||||
15 | * @author Mateusz Zalewski <[email protected]> |
||||||
16 | * @author Łukasz Chruściel <[email protected]> |
||||||
17 | * @author Diego D'amico <[email protected]> |
||||||
18 | */ |
||||||
19 | final class TableRendererSpec extends ObjectBehavior |
||||||
20 | { |
||||||
21 | function let(Environment $templating) |
||||||
0 ignored issues
–
show
|
|||||||
22 | { |
||||||
23 | $this->beConstructedWith($templating); |
||||||
24 | } |
||||||
25 | |||||||
26 | function it_is_initializable() |
||||||
0 ignored issues
–
show
|
|||||||
27 | { |
||||||
28 | $this->shouldHaveType(TableRenderer::class); |
||||||
29 | } |
||||||
30 | |||||||
31 | function it_should_implement_renderer_interface() |
||||||
32 | { |
||||||
33 | $this->shouldImplement(RendererInterface::class); |
||||||
34 | } |
||||||
35 | |||||||
36 | function it_renders_data_with_given_configuration(ReportInterface $report, Data $reportData, EngineInterface $templating) |
||||||
37 | { |
||||||
38 | $reportData->getLabels()->willReturn(['month', 'user_total']); |
||||||
39 | $reportData->getData()->willReturn(['month1' => '50', 'month2' => '40']); |
||||||
40 | |||||||
41 | $renderData = [ |
||||||
42 | 'report' => $report, |
||||||
43 | 'values' => ['month1' => '50', 'month2' => '40'], |
||||||
44 | 'labels' => ['month', 'user_total'], |
||||||
45 | ]; |
||||||
46 | |||||||
47 | $report->getRendererConfiguration()->willReturn(['template' => '@OdiseoSyliusReportPlugin/Table/default.html.twig']); |
||||||
48 | |||||||
49 | $templating->render('@OdiseoSyliusReportPlugin/Table/default.html.twig', [ |
||||||
50 | 'data' => $renderData, |
||||||
51 | 'configuration' => ['template' => '@OdiseoSyliusReportPlugin/Table/default.html.twig'], |
||||||
52 | ])->willReturn('<div>Table Report</div>'); |
||||||
53 | |||||||
54 | $this->render($report, $reportData)->shouldReturn('<div>Table Report</div>'); |
||||||
0 ignored issues
–
show
The method
render() does not exist on spec\Odiseo\SyliusReport...derer\TableRendererSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
55 | } |
||||||
56 | |||||||
57 | function it_renders_a_no_data_with_given_configuration(ReportInterface $report, Data $reportData, EngineInterface $templating) |
||||||
58 | { |
||||||
59 | $reportData->getLabels()->willReturn(['month', 'user_total']); |
||||||
60 | $reportData->getData()->willReturn([]); |
||||||
61 | |||||||
62 | $report->getRendererConfiguration()->willReturn(['template' => '@OdiseoSyliusReportPlugin/noDataTemplate.html.twig']); |
||||||
63 | |||||||
64 | $templating->render('@OdiseoSyliusReportPlugin/noDataTemplate.html.twig', [ |
||||||
65 | 'report' => $report, |
||||||
66 | ])->willReturn('<div>No Data</div>'); |
||||||
67 | |||||||
68 | $this->render($report, $reportData)->shouldReturn('<div>No Data</div>'); |
||||||
69 | } |
||||||
70 | |||||||
71 | function it_is_a_table_type() |
||||||
72 | { |
||||||
73 | $this->getType()->shouldReturn(TableConfigurationType::class); |
||||||
0 ignored issues
–
show
The method
getType() does not exist on spec\Odiseo\SyliusReport...derer\TableRendererSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
74 | } |
||||||
75 | } |
||||||
76 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.