1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Odiseo\SyliusReportPlugin\Renderer; |
4
|
|
|
|
5
|
|
|
use Odiseo\SyliusReportPlugin\DataFetcher\Data; |
6
|
|
|
use Odiseo\SyliusReportPlugin\Form\Type\Renderer\ChartConfigurationType; |
7
|
|
|
use Odiseo\SyliusReportPlugin\Model\ReportInterface; |
8
|
|
|
use Odiseo\SyliusReportPlugin\Renderer\ChartRenderer; |
9
|
|
|
use Odiseo\SyliusReportPlugin\Renderer\RendererInterface; |
10
|
|
|
use PhpSpec\ObjectBehavior; |
11
|
|
|
use Symfony\Component\Templating\EngineInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @author Mateusz Zalewski <[email protected]> |
15
|
|
|
* @author Łukasz Chruściel <[email protected]> |
16
|
|
|
* @author Diego D'amico <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
final class ChartRendererSpec extends ObjectBehavior |
19
|
|
|
{ |
20
|
|
|
function let(EngineInterface $templating) |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
$this->beConstructedWith($templating); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
function it_is_initializable() |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
$this->shouldHaveType(ChartRenderer::class); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_should_implement_renderer_interface() |
31
|
|
|
{ |
32
|
|
|
$this->shouldImplement(RendererInterface::class); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function it_renders_data_with_given_configuration(ReportInterface $report, Data $reportData, $templating) |
36
|
|
|
{ |
37
|
|
|
$reportData->getData()->willReturn(['month1' => '50', 'month2' => '40']); |
38
|
|
|
|
39
|
|
|
$renderData = [ |
40
|
|
|
'report' => $report, |
41
|
|
|
'values' => ['month1' => '50', 'month2' => '40'], |
42
|
|
|
'labels' => ['month1', 'month2'], |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
$report->getRendererConfiguration()->willReturn(['template' => '@OdiseoSyliusReportPlugin/Chart/default.html.twig']); |
46
|
|
|
|
47
|
|
|
$templating->render('@OdiseoSyliusReportPlugin/Chart/default.html.twig', [ |
48
|
|
|
'data' => $renderData, |
49
|
|
|
'configuration' => ['template' => '@OdiseoSyliusReportPlugin/Chart/default.html.twig'], |
50
|
|
|
])->willReturn('<div>Chart Report</div>'); |
51
|
|
|
|
52
|
|
|
$this->render($report, $reportData)->shouldReturn('<div>Chart Report</div>'); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
function it_is_a_chart_type() |
56
|
|
|
{ |
57
|
|
|
$this->getType()->shouldReturn(ChartConfigurationType::class); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
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.