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\Model\ChannelInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author Jan Góralski <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
final class PerChannelCustomerStatisticsSpec extends ObjectBehavior |
22
|
|
|
{ |
23
|
|
|
function let(ChannelInterface $channel) |
24
|
|
|
{ |
25
|
|
|
$this->beConstructedWith(10, 20000, $channel); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
function it_is_initializable() |
29
|
|
|
{ |
30
|
|
|
$this->shouldHaveType(PerChannelCustomerStatistics::class); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function it_throws_an_exception_if_any_of_values_besides_channel_is_not_an_int(ChannelInterface $channel) |
34
|
|
|
{ |
35
|
|
|
$this->beConstructedWith(new \Datetime(), [], $channel); |
36
|
|
|
|
37
|
|
|
$this |
38
|
|
|
->shouldThrow(\InvalidArgumentException::class) |
39
|
|
|
->duringInstantiation() |
40
|
|
|
; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function it_has_number_of_orders() |
44
|
|
|
{ |
45
|
|
|
$this->getOrdersCount()->shouldReturn(10); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_has_the_combined_value_of_all_orders() |
49
|
|
|
{ |
50
|
|
|
$this->getOrdersValue()->shouldReturn(20000); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function it_has_a_clone_of_the_origin_channel_of_orders(ChannelInterface $channel) |
54
|
|
|
{ |
55
|
|
|
$this->getChannel()->shouldBeLike($channel); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
function it_has_an_average_value_of_an_order() |
59
|
|
|
{ |
60
|
|
|
$this->getAverageOrderValue()->shouldReturn(2000); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|