Passed
Pull Request — master (#5)
by
unknown
04:04
created

ProductAttributesFinderSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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(
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
37
    {
38
        $this->shouldHaveType(ProductAttributesFinder::class);
39
    }
40
41
    function it_implements_product_attributes_finder_interface(): void
42
    {
43
        $this->shouldHaveType(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);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Elastica\Query\AbstractQuery. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
        $attributesByTaxonQueryBuilder->buildQuery(['taxons' => 'book'])->/** @scrutinizer ignore-call */ willReturn($query);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
56
        $attributesFinder->find($query)->willReturn([]);
57
58
        $this->findByTaxon($taxon)->shouldBeEqualTo([]);
0 ignored issues
show
Bug introduced by
The method findByTaxon() does not exist on spec\BitBag\SyliusElasti...uctAttributesFinderSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

58
        $this->/** @scrutinizer ignore-call */ 
59
               findByTaxon($taxon)->shouldBeEqualTo([]);
Loading history...
59
    }
60
}
61