Passed
Push — master ( 979f6d...757493 )
by US
08:39 queued 11s
created

ShopProductsFinderSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 4
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace spec\BitBag\SyliusElasticsearchPlugin\Finder;
14
15
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\PaginationDataHandlerInterface;
16
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\SortDataHandlerInterface;
17
use BitBag\SyliusElasticsearchPlugin\Finder\ShopProductsFinder;
18
use BitBag\SyliusElasticsearchPlugin\Finder\ShopProductsFinderInterface;
19
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
20
use Elastica\Query\AbstractQuery;
21
use FOS\ElasticaBundle\Finder\PaginatedFinderInterface;
22
use Pagerfanta\Pagerfanta;
23
use PhpSpec\ObjectBehavior;
24
use Prophecy\Argument;
25
26
final class ShopProductsFinderSpec extends ObjectBehavior
27
{
28
    function let(
29
        QueryBuilderInterface $shopProductsQueryBuilder,
30
        PaginatedFinderInterface $productFinder
31
    ): void {
32
        $this->beConstructedWith(
33
            $shopProductsQueryBuilder,
34
            $productFinder
35
        );
36
    }
37
38
    function it_is_initializable(): void
39
    {
40
        $this->shouldHaveType(ShopProductsFinder::class);
41
    }
42
43
    function it_implements_shop_products_finder_interface(): void
44
    {
45
        $this->shouldHaveType(ShopProductsFinderInterface::class);
46
    }
47
48
    function it_finds(
49
        QueryBuilderInterface $shopProductsQueryBuilder,
50
        PaginatedFinderInterface $productFinder,
51
        AbstractQuery $boolQuery,
52
        Pagerfanta $pagerfanta
53
    ): void {
54
        $data = [
55
            SortDataHandlerInterface::SORT_INDEX => null,
56
            PaginationDataHandlerInterface::PAGE_INDEX => null,
57
            PaginationDataHandlerInterface::LIMIT_INDEX => null,
58
        ];
59
60
        $shopProductsQueryBuilder->buildQuery($data)->willReturn($boolQuery);
61
62
        $productFinder->findPaginated(Argument::any())->willReturn($pagerfanta);
63
64
        $this->find($data)->shouldBeEqualTo($pagerfanta);
65
    }
66
}
67