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

ShopProductsQueryBuilderSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 7
dl 0
loc 19
rs 9.9332
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\QueryBuilder;
14
15
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
16
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\ShopProductsQueryBuilder;
17
use Elastica\Query\AbstractQuery;
18
use Elastica\Query\BoolQuery;
19
use PhpSpec\ObjectBehavior;
20
21
final class ShopProductsQueryBuilderSpec extends ObjectBehavior
22
{
23
    function let(
24
        QueryBuilderInterface $isEnabledQueryBuilder,
25
        QueryBuilderInterface $hasChannelQueryBuilder,
26
        QueryBuilderInterface $containsNameQueryBuilder,
27
        QueryBuilderInterface $hasTaxonQueryBuilder,
28
        QueryBuilderInterface $hasOptionsQueryBuilder,
29
        QueryBuilderInterface $hasAttributesQueryBuilder,
30
        QueryBuilderInterface $hasPriceBetweenQueryBuilder
31
    ): void {
32
        $this->beConstructedWith(
33
            $isEnabledQueryBuilder,
34
            $hasChannelQueryBuilder,
35
            $containsNameQueryBuilder,
36
            $hasTaxonQueryBuilder,
37
            $hasOptionsQueryBuilder,
38
            $hasAttributesQueryBuilder,
39
            $hasPriceBetweenQueryBuilder,
40
            'option',
41
            'attribute'
42
        );
43
    }
44
45
    function it_is_initializable(): void
46
    {
47
        $this->shouldHaveType(ShopProductsQueryBuilder::class);
48
    }
49
50
    function it_implements_query_builder_interface(): void
51
    {
52
        $this->shouldHaveType(QueryBuilderInterface::class);
53
    }
54
55
    function it_builds_query(
56
        QueryBuilderInterface $isEnabledQueryBuilder,
57
        QueryBuilderInterface $hasChannelQueryBuilder,
58
        QueryBuilderInterface $containsNameQueryBuilder,
59
        QueryBuilderInterface $hasTaxonQueryBuilder,
60
        QueryBuilderInterface $hasOptionsQueryBuilder,
61
        QueryBuilderInterface $hasAttributesQueryBuilder,
62
        QueryBuilderInterface $hasPriceBetweenQueryBuilder,
63
        AbstractQuery $query
64
    ): void {
65
        $containsNameQueryBuilder->buildQuery(['option' => ['XL'], 'attribute' => ['Red']])->willReturn($query);
66
        $isEnabledQueryBuilder->buildQuery(['option' => ['XL'], 'attribute' => ['Red']])->willReturn($query);
67
        $hasTaxonQueryBuilder->buildQuery(['option' => ['XL'], 'attribute' => ['Red']])->willReturn($query);
68
        $hasChannelQueryBuilder->buildQuery(['option' => ['XL'], 'attribute' => ['Red']])->willReturn($query);
69
        $hasOptionsQueryBuilder->buildQuery(['option' => 'option', 'option_values' => ['XL']])->willReturn($query);
70
        $hasAttributesQueryBuilder->buildQuery(['attribute' => 'attribute', 'attribute_values' => ['Red']])->willReturn($query);
71
        $hasPriceBetweenQueryBuilder->buildQuery(['option' => ['XL'], 'attribute' => ['Red']])->willReturn($query);
72
73
        $this->buildQuery([
74
            'option' => ['XL'],
75
            'attribute' => ['Red'],
76
        ])->shouldBeAnInstanceOf(BoolQuery::class);
77
    }
78
}
79