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

DashboardStatisticsProviderSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 30
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_dashboard_statistics_provider_interface() 0 4 1
A it_obtains_order_and_customer_statistics_from_the_repositories() 0 12 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 PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Component\Core\Dashboard\DashboardStatistics;
17
use Sylius\Component\Core\Dashboard\DashboardStatisticsProvider;
18
use Sylius\Component\Core\Dashboard\DashboardStatisticsProviderInterface;
19
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
20
use Sylius\Component\User\Repository\CustomerRepositoryInterface;
21
22
/**
23
 * @mixin DashboardStatisticsProvider
24
 *
25
 * @author Paweł Jędrzejewski <[email protected]>
26
 */
27
class DashboardStatisticsProviderSpec extends ObjectBehavior
28
{
29
    function let(OrderRepositoryInterface $orderRepository, CustomerRepositoryInterface $customerRepository)
30
    {
31
        $this->beConstructedWith($orderRepository, $customerRepository);
32
    }
33
34
    function it_is_initializable()
35
    {
36
        $this->shouldHaveType('Sylius\Component\Core\Dashboard\DashboardStatisticsProvider');
37
    }
38
    
39
    function it_implements_dashboard_statistics_provider_interface()
40
    {
41
        $this->shouldImplement(DashboardStatisticsProviderInterface::class);
42
    }
43
44
    function it_obtains_order_and_customer_statistics_from_the_repositories(
45
        OrderRepositoryInterface $orderRepository,
46
        CustomerRepositoryInterface $customerRepository
47
    ) {
48
        $expectedStats = new DashboardStatistics(450, 2, 6);
49
       
50
        $orderRepository->getTotalSales()->willReturn(450);
51
        $orderRepository->count()->willReturn(2);
52
        $customerRepository->count()->willReturn(6);
53
        
54
        $this->getStatistics()->shouldBeLike($expectedStats);
55
    }
56
}
57