Completed
Pull Request — master (#51)
by Konrad
03:32
created

NamedProductsFinderSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_a_named_products_finder() 0 3 1
A let() 0 5 1
A it_finds_by_partial_name_of_products() 0 10 1
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\NamedProductsFinderInterface;
16
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
17
use Elastica\Query\AbstractQuery;
18
use FOS\ElasticaBundle\Finder\FinderInterface;
19
use PhpSpec\ObjectBehavior;
20
21
final class NamedProductsFinderSpec extends ObjectBehavior
22
{
23
    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...
24
        QueryBuilderInterface $productsByPartialNameQueryBuilder,
25
        FinderInterface $productsFinder
26
    ): void {
27
        $this->beConstructedWith($productsByPartialNameQueryBuilder, $productsFinder);
28
    }
29
30
    function it_is_a_named_products_finder(): 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...
31
    {
32
        $this->shouldImplement(NamedProductsFinderInterface::class);
33
    }
34
35
    function it_finds_by_partial_name_of_products(
36
        QueryBuilderInterface $productsByPartialNameQueryBuilder,
37
        FinderInterface $productsFinder,
38
        AbstractQuery $query
39
    ): void {
40
        $productsByPartialNameQueryBuilder->buildQuery(['name' => 'part'])->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

40
        $productsByPartialNameQueryBuilder->buildQuery(['name' => 'part'])->/** @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...
41
42
        $productsFinder->find($query)->willReturn([]);
43
44
        $this->findByNamePart('part')->shouldBeArray();
0 ignored issues
show
Bug introduced by
The method findByNamePart() does not exist on spec\BitBag\SyliusElasti...NamedProductsFinderSpec. 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

44
        $this->/** @scrutinizer ignore-call */ 
45
               findByNamePart('part')->shouldBeArray();
Loading history...
45
    }
46
}
47