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

HasPriceBetweenQueryBuilderSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 3 1
A let() 0 9 1
A it_implements_query_builder_interface() 0 3 1
A it_builds_query() 0 19 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\QueryBuilder;
14
15
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
16
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\PriceNameResolverInterface;
17
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\HasPriceBetweenQueryBuilder;
18
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
19
use Elastica\Query\Range;
20
use PhpSpec\ObjectBehavior;
21
use Sylius\Component\Channel\Context\ChannelContextInterface;
22
use Sylius\Component\Core\Model\ChannelInterface;
23
24
final class HasPriceBetweenQueryBuilderSpec extends ObjectBehavior
25
{
26
    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...
27
        PriceNameResolverInterface $priceNameResolver,
28
        ConcatedNameResolverInterface $channelPricingNameResolver,
29
        ChannelContextInterface $channelContext
30
    ): void {
31
        $this->beConstructedWith(
32
            $priceNameResolver,
33
            $channelPricingNameResolver,
34
            $channelContext
35
        );
36
    }
37
38
    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...
39
    {
40
        $this->shouldHaveType(HasPriceBetweenQueryBuilder::class);
41
    }
42
43
    function it_implements_query_builder_interface(): void
44
    {
45
        $this->shouldHaveType(QueryBuilderInterface::class);
46
    }
47
48
    function it_builds_query(
49
        PriceNameResolverInterface $priceNameResolver,
50
        ChannelContextInterface $channelContext,
51
        ChannelInterface $channel,
52
        ConcatedNameResolverInterface $channelPricingNameResolver
53
    ): void {
54
        $channel->getCode()->willReturn('web');
55
56
        $channelContext->getChannel()->willReturn($channel);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Channel\Model\ChannelInterface. ( Ignorable by Annotation )

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

56
        $channelContext->getChannel()->/** @scrutinizer ignore-call */ willReturn($channel);

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...
57
58
        $priceNameResolver->resolveMinPriceName()->willReturn('min_price');
59
        $priceNameResolver->resolveMaxPriceName()->willReturn('max_price');
60
61
        $channelPricingNameResolver->resolvePropertyName('web')->willReturn('web');
62
63
        $this->buildQuery([
0 ignored issues
show
Bug introduced by
The method buildQuery() does not exist on spec\BitBag\SyliusElasti...BetweenQueryBuilderSpec. 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

63
        $this->/** @scrutinizer ignore-call */ 
64
               buildQuery([
Loading history...
64
            'min_price' => '200',
65
            'max_price' => '1000',
66
        ])->shouldBeAnInstanceOf(Range::class);
67
    }
68
}
69