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
|
|
|
use Sylius\Component\Currency\Context\CurrencyContextInterface; |
24
|
|
|
use Sylius\Component\Currency\Converter\CurrencyConverterInterface; |
25
|
|
|
use Sylius\Component\Currency\Model\CurrencyInterface; |
26
|
|
|
|
27
|
|
|
final class HasPriceBetweenQueryBuilderSpec extends ObjectBehavior |
28
|
|
|
{ |
29
|
|
|
function let( |
30
|
|
|
PriceNameResolverInterface $priceNameResolver, |
31
|
|
|
ConcatedNameResolverInterface $channelPricingNameResolver, |
32
|
|
|
ChannelContextInterface $channelContext, |
33
|
|
|
CurrencyContextInterface $currencyContext, |
34
|
|
|
CurrencyConverterInterface $currencyConverter |
35
|
|
|
): void { |
36
|
|
|
$this->beConstructedWith( |
37
|
|
|
$priceNameResolver, |
38
|
|
|
$channelPricingNameResolver, |
39
|
|
|
$channelContext, |
40
|
|
|
$currencyContext, |
41
|
|
|
$currencyConverter |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function it_is_initializable(): void |
46
|
|
|
{ |
47
|
|
|
$this->shouldHaveType(HasPriceBetweenQueryBuilder::class); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function it_implements_query_builder_interface(): void |
51
|
|
|
{ |
52
|
|
|
$this->shouldHaveType(QueryBuilderInterface::class); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
function it_builds_query( |
56
|
|
|
PriceNameResolverInterface $priceNameResolver, |
57
|
|
|
ChannelContextInterface $channelContext, |
58
|
|
|
ChannelInterface $channel, |
59
|
|
|
CurrencyContextInterface $currencyContext, |
60
|
|
|
CurrencyInterface $currency, |
61
|
|
|
ConcatedNameResolverInterface $channelPricingNameResolver |
62
|
|
|
): void { |
63
|
|
|
$channel->getCode()->willReturn('web'); |
64
|
|
|
$channelContext->getChannel()->willReturn($channel); |
65
|
|
|
$priceNameResolver->resolveMinPriceName()->willReturn('min_price'); |
66
|
|
|
$priceNameResolver->resolveMaxPriceName()->willReturn('max_price'); |
67
|
|
|
$channel->getBaseCurrency()->willReturn($currency); |
68
|
|
|
$currency->getCode()->willReturn('USD'); |
69
|
|
|
$currencyContext->getCurrencyCode()->willReturn('USD'); |
70
|
|
|
|
71
|
|
|
$channelPricingNameResolver->resolvePropertyName('web')->willReturn('web'); |
72
|
|
|
|
73
|
|
|
$this->buildQuery([ |
74
|
|
|
'min_price' => '200', |
75
|
|
|
'max_price' => '1000', |
76
|
|
|
])->shouldBeAnInstanceOf(Range::class); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|