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

ProductAttributesFinderSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 36
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\Finder\ProductAttributesFinder;
16
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface;
17
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
18
use Elastica\Query\AbstractQuery;
19
use FOS\ElasticaBundle\Finder\FinderInterface;
20
use PhpSpec\ObjectBehavior;
21
use Sylius\Component\Core\Model\TaxonInterface;
22
23
final class ProductAttributesFinderSpec extends ObjectBehavior
24
{
25
    function let(
26
        FinderInterface $attributesFinder,
27
        QueryBuilderInterface $attributesByTaxonQueryBuilder
28
    ): void {
29
        $this->beConstructedWith(
30
            $attributesFinder,
31
            $attributesByTaxonQueryBuilder,
32
            'taxons'
33
        );
34
    }
35
36
    function it_is_initializable(): void
37
    {
38
        $this->shouldHaveType(ProductAttributesFinder::class);
39
    }
40
41
    function it_implements_product_attributes_finder_interface(): void
42
    {
43
        $this->shouldImplement(ProductAttributesFinderInterface::class);
44
    }
45
46
    function it_finds_by_taxon(
47
        TaxonInterface $taxon,
48
        QueryBuilderInterface $attributesByTaxonQueryBuilder,
49
        FinderInterface $attributesFinder,
50
        AbstractQuery $query
51
    ): void {
52
        $taxon->getCode()->willReturn('book');
53
54
        $attributesByTaxonQueryBuilder->buildQuery(['taxons' => 'book'])->willReturn($query);
55
56
        $attributesFinder->find($query, 20)->willReturn([]);
57
58
        $this->findByTaxon($taxon)->shouldBeEqualTo([]);
59
    }
60
}
61