|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Odiseo\SyliusReportPlugin\Model; |
|
4
|
|
|
|
|
5
|
|
|
use Odiseo\SyliusReportPlugin\DataFetcher\DefaultDataFetchers; |
|
6
|
|
|
use Odiseo\SyliusReportPlugin\Model\Report; |
|
7
|
|
|
use Odiseo\SyliusReportPlugin\Model\ReportInterface; |
|
8
|
|
|
use Odiseo\SyliusReportPlugin\Renderer\DefaultRenderers; |
|
9
|
|
|
use PhpSpec\ObjectBehavior; |
|
10
|
|
|
use Prophecy\Argument; |
|
11
|
|
|
use Sylius\Component\Resource\Model\CodeAwareInterface; |
|
12
|
|
|
use Sylius\Component\Resource\Model\ResourceInterface; |
|
13
|
|
|
use Sylius\Component\Resource\Model\TimestampableInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @author Diego D'amico <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class ReportSpec extends ObjectBehavior |
|
19
|
|
|
{ |
|
20
|
|
|
function it_is_initializable() |
|
|
|
|
|
|
21
|
|
|
{ |
|
22
|
|
|
$this->shouldHaveType(Report::class); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
function it_implements_report_interface(): void |
|
26
|
|
|
{ |
|
27
|
|
|
$this->shouldImplement(ReportInterface::class); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
function it_implements_resource_interface(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->shouldImplement(ResourceInterface::class); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function it_implements_code_aware_interface(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$this->shouldImplement(CodeAwareInterface::class); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function it_implements_timestamplable_interface(): void |
|
41
|
|
|
{ |
|
42
|
|
|
$this->shouldImplement(TimestampableInterface::class); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function it_has_no_id_by_default(): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->getId()->shouldReturn(null); |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
function it_has_no_name_by_default(): void |
|
51
|
|
|
{ |
|
52
|
|
|
$this->getName()->shouldReturn(null); |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
function it_has_no_code_by_default(): void |
|
56
|
|
|
{ |
|
57
|
|
|
$this->getCode()->shouldReturn(null); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
function it_has_no_description_by_default(): void |
|
61
|
|
|
{ |
|
62
|
|
|
$this->getDescription()->shouldReturn(null); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
function it_has_a_default_renderer(): void |
|
66
|
|
|
{ |
|
67
|
|
|
$this->getRenderer()->shouldReturn(DefaultRenderers::TABLE); |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
function it_has_a_default_data_fetcher(): void |
|
71
|
|
|
{ |
|
72
|
|
|
$this->getDataFetcher()->shouldReturn(DefaultDataFetchers::USER_REGISTRATION); |
|
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
function it_has_a_default_renderer_configuration(): void |
|
76
|
|
|
{ |
|
77
|
|
|
$this->getRendererConfiguration()->shouldHaveCount(0); |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
function it_has_a_default_data_fetcher_configuration(): void |
|
81
|
|
|
{ |
|
82
|
|
|
$this->getDataFetcherConfiguration()->shouldHaveCount(1); |
|
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
function it_is_timestampable(): void |
|
86
|
|
|
{ |
|
87
|
|
|
$dateTime = new \DateTime(); |
|
88
|
|
|
$this->setCreatedAt($dateTime); |
|
|
|
|
|
|
89
|
|
|
$this->getCreatedAt()->shouldReturn($dateTime); |
|
|
|
|
|
|
90
|
|
|
$this->setUpdatedAt($dateTime); |
|
|
|
|
|
|
91
|
|
|
$this->getUpdatedAt()->shouldReturn($dateTime); |
|
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
function it_allows_access_via_properties(): void |
|
95
|
|
|
{ |
|
96
|
|
|
$this->setCode('report'); |
|
|
|
|
|
|
97
|
|
|
$this->getCode()->shouldReturn('report'); |
|
98
|
|
|
|
|
99
|
|
|
$this->setName('Report'); |
|
|
|
|
|
|
100
|
|
|
$this->getName()->shouldReturn('Report'); |
|
101
|
|
|
|
|
102
|
|
|
$this->setDescription('Report description'); |
|
|
|
|
|
|
103
|
|
|
$this->getDescription()->shouldReturn('Report description'); |
|
104
|
|
|
|
|
105
|
|
|
$this->setDataFetcher(DefaultDataFetchers::NUMBER_OF_ORDERS); |
|
|
|
|
|
|
106
|
|
|
$this->getDataFetcher()->shouldReturn(DefaultDataFetchers::NUMBER_OF_ORDERS); |
|
107
|
|
|
|
|
108
|
|
|
$this->setDataFetcherConfiguration(['test' => 'yes']); |
|
|
|
|
|
|
109
|
|
|
$this->getDataFetcherConfiguration()->shouldReturn(['test' => 'yes']); |
|
110
|
|
|
|
|
111
|
|
|
$this->setRenderer(DefaultRenderers::CHART); |
|
|
|
|
|
|
112
|
|
|
$this->getRenderer()->shouldReturn(DefaultRenderers::CHART); |
|
113
|
|
|
|
|
114
|
|
|
$this->setRendererConfiguration(['test' => 'yes']); |
|
|
|
|
|
|
115
|
|
|
$this->getRendererConfiguration()->shouldReturn(['test' => 'yes']); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
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.