Completed
Push — master ( d54afb...01173a )
by Kamil
26:45
created

DashboardStatisticsSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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