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

DashboardStatisticsSpec   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 8
c 3
b 1
f 2
lcom 1
cbo 2
dl 0
loc 49
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_throws_exception_if_any_of_values_if_not_an_int() 0 9 1
A it_has_total_sales_stat() 0 4 1
A it_has_new_orders_stat() 0 4 1
A ith_has_new_customers_stat() 0 4 1
A it_calculates_average_order_value() 0 4 1
A it_returns_0_as_average_order_value_when_there_are_no_orders() 0 6 1
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