Files
SyliusElasticsearchPlugin/spec/QueryBuilder/HasPriceBetweenQueryBuilderSpec.php
Mikołaj Król 36f5a0a9e4 Fix the build
2019-03-21 13:49:32 +01:00

79 lines
2.8 KiB
PHP

<?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on mikolaj.krol@bitbag.pl.
*/
declare(strict_types=1);
namespace spec\BitBag\SyliusElasticsearchPlugin\QueryBuilder;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\PriceNameResolverInterface;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\HasPriceBetweenQueryBuilder;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
use Elastica\Query\Range;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Currency\Context\CurrencyContextInterface;
use Sylius\Component\Currency\Converter\CurrencyConverterInterface;
use Sylius\Component\Currency\Model\CurrencyInterface;
final class HasPriceBetweenQueryBuilderSpec extends ObjectBehavior
{
function let(
PriceNameResolverInterface $priceNameResolver,
ConcatedNameResolverInterface $channelPricingNameResolver,
ChannelContextInterface $channelContext,
CurrencyContextInterface $currencyContext,
CurrencyConverterInterface $currencyConverter
): void {
$this->beConstructedWith(
$priceNameResolver,
$channelPricingNameResolver,
$channelContext,
$currencyContext,
$currencyConverter
);
}
function it_is_initializable(): void
{
$this->shouldHaveType(HasPriceBetweenQueryBuilder::class);
}
function it_implements_query_builder_interface(): void
{
$this->shouldHaveType(QueryBuilderInterface::class);
}
function it_builds_query(
PriceNameResolverInterface $priceNameResolver,
ChannelContextInterface $channelContext,
ChannelInterface $channel,
CurrencyContextInterface $currencyContext,
CurrencyInterface $currency,
ConcatedNameResolverInterface $channelPricingNameResolver
): void {
$channel->getCode()->willReturn('web');
$channelContext->getChannel()->willReturn($channel);
$priceNameResolver->resolveMinPriceName()->willReturn('min_price');
$priceNameResolver->resolveMaxPriceName()->willReturn('max_price');
$channel->getBaseCurrency()->willReturn($currency);
$currency->getCode()->willReturn('USD');
$currencyContext->getCurrencyCode()->willReturn('USD');
$channelPricingNameResolver->resolvePropertyName('web')->willReturn('web');
$this->buildQuery([
'min_price' => '200',
'max_price' => '1000',
])->shouldBeAnInstanceOf(Range::class);
}
}