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( |
|
|
|
|
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 |
|
|
|
|
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); |
|
|
|
|
57
|
|
|
|
58
|
|
|
$priceNameResolver->resolveMinPriceName()->willReturn('min_price'); |
59
|
|
|
$priceNameResolver->resolveMaxPriceName()->willReturn('max_price'); |
60
|
|
|
|
61
|
|
|
$channelPricingNameResolver->resolvePropertyName('web')->willReturn('web'); |
62
|
|
|
|
63
|
|
|
$this->buildQuery([ |
|
|
|
|
64
|
|
|
'min_price' => '200', |
65
|
|
|
'max_price' => '1000', |
66
|
|
|
])->shouldBeAnInstanceOf(Range::class); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.