|
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\Dashboard; |
|
13
|
|
|
|
|
14
|
|
|
use Sylius\Component\Core\Dashboard\DashboardStatistics; |
|
15
|
|
|
use PhpSpec\ObjectBehavior; |
|
16
|
|
|
use Prophecy\Argument; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @mixin DashboardStatistics |
|
20
|
|
|
* |
|
21
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class DashboardStatisticsSpec extends ObjectBehavior |
|
24
|
|
|
{ |
|
25
|
|
|
function let() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->beConstructedWith(2564, 24, 10); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
function it_is_initializable() |
|
31
|
|
|
{ |
|
32
|
|
|
$this->shouldHaveType('Sylius\Component\Core\Dashboard\DashboardStatistics'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function it_throws_exception_if_any_of_values_if_not_an_int() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->beConstructedWith('string', 2.5, 'foo'); |
|
38
|
|
|
|
|
39
|
|
|
$this |
|
40
|
|
|
->shouldThrow(\InvalidArgumentException::class) |
|
41
|
|
|
->duringInstantiation() |
|
42
|
|
|
; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function it_has_total_sales_stat() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->getTotalSales()->shouldReturn(2564); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
function it_has_new_orders_stat() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->getNumberOfNewOrders()->shouldReturn(24); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
function ith_has_new_customers_stat() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->getNumberOfNewCustomers()->shouldReturn(10); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
function it_calculates_average_order_value() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->getAverageOrderValue()->shouldReturn(107); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
function it_returns_0_as_average_order_value_when_there_are_no_orders() |
|
66
|
|
|
{ |
|
67
|
|
|
$this->beConstructedWith(0, 0, 2); |
|
68
|
|
|
|
|
69
|
|
|
$this->getAverageOrderValue()->shouldReturn(0); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|