|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace spec\Sylius\Component\Core\Customer\Statistics; |
|
13
|
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
|
15
|
|
|
use Sylius\Component\Core\Customer\Statistics\PerChannelCustomerStatistics; |
|
16
|
|
|
use Sylius\Component\Core\Customer\Statistics\CustomerStatistics; |
|
17
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Jan Góralski <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
final class CustomerStatisticsSpec extends ObjectBehavior |
|
23
|
|
|
{ |
|
24
|
|
|
function let() |
|
25
|
|
|
{ |
|
26
|
|
|
$this->beConstructedWith([]); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function it_is_initializable() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->shouldHaveType(CustomerStatistics::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_throws_an_exception_when_array_does_not_contain_only_per_channel_statistics() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->beConstructedWith([new \DateTime()]); |
|
37
|
|
|
|
|
38
|
|
|
$this |
|
39
|
|
|
->shouldThrow(\InvalidArgumentException::class) |
|
40
|
|
|
->duringInstantiation() |
|
41
|
|
|
; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
function it_returns_zero_if_there_are_no_per_channel_statistics() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->getAllOrdersCount()->shouldReturn(0); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function it_has_number_of_all_orders(ChannelInterface $channel) { |
|
50
|
|
|
$firstStatistics = new PerChannelCustomerStatistics(110, 120, $channel->getWrappedObject()); |
|
51
|
|
|
$secondStatistics = new PerChannelCustomerStatistics(13, 120, $channel->getWrappedObject()); |
|
52
|
|
|
|
|
53
|
|
|
$this->beConstructedWith([$firstStatistics, $secondStatistics]); |
|
54
|
|
|
|
|
55
|
|
|
$this->getAllOrdersCount()->shouldReturn(123); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
function it_has_an_array_of_statistics_per_channel(ChannelInterface $channel) { |
|
59
|
|
|
$firstStatistics = new PerChannelCustomerStatistics(110, 120, $channel->getWrappedObject()); |
|
60
|
|
|
$secondStatistics = new PerChannelCustomerStatistics(13, 120, $channel->getWrappedObject()); |
|
61
|
|
|
|
|
62
|
|
|
$this->beConstructedWith([$firstStatistics, $secondStatistics]); |
|
63
|
|
|
|
|
64
|
|
|
$this->getPerChannelsStatistics()->shouldReturn([$firstStatistics, $secondStatistics]); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|