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
|
|
|
|