odiseoteam /
SyliusReportPlugin
| 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 | 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 ChartRendererSpec 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(ChartRenderer::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, $templating) |
||||||
| 37 | { |
||||||
| 38 | $reportData->getData()->willReturn(['month1' => '50', 'month2' => '40']); |
||||||
| 39 | $reportData->getLabels()->willReturn(['month', 'sales']); |
||||||
| 40 | |||||||
| 41 | $renderData = [ |
||||||
| 42 | 'report' => $report, |
||||||
| 43 | 'values' => ['month1' => '50', 'month2' => '40'], |
||||||
| 44 | 'labels' => ['month', 'sales'], |
||||||
| 45 | ]; |
||||||
| 46 | |||||||
| 47 | $report->getRendererConfiguration()->willReturn(['template' => '@OdiseoSyliusReportPlugin/Chart/default.html.twig']); |
||||||
| 48 | |||||||
| 49 | $templating->render('@OdiseoSyliusReportPlugin/Chart/default.html.twig', [ |
||||||
| 50 | 'data' => $renderData, |
||||||
| 51 | 'configuration' => ['template' => '@OdiseoSyliusReportPlugin/Chart/default.html.twig'], |
||||||
| 52 | ])->willReturn('<div>Chart Report</div>'); |
||||||
| 53 | |||||||
| 54 | $this->render($report, $reportData)->shouldReturn('<div>Chart Report</div>'); |
||||||
|
0 ignored issues
–
show
The method
render() does not exist on spec\Odiseo\SyliusReport...derer\ChartRendererSpec. 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
Loading history...
|
|||||||
| 55 | } |
||||||
| 56 | |||||||
| 57 | function it_is_a_chart_type() |
||||||
| 58 | { |
||||||
| 59 | $this->getType()->shouldReturn(ChartConfigurationType::class); |
||||||
|
0 ignored issues
–
show
The method
getType() does not exist on spec\Odiseo\SyliusReport...derer\ChartRendererSpec. 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
Loading history...
|
|||||||
| 60 | } |
||||||
| 61 | } |
||||||
| 62 |
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.