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\QueryBuilder\ContainsNameQueryBuilder; |
17
|
|
|
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface; |
18
|
|
|
use Elastica\Query\Match; |
19
|
|
|
use PhpSpec\ObjectBehavior; |
20
|
|
|
use Sylius\Component\Locale\Context\LocaleContextInterface; |
21
|
|
|
|
22
|
|
|
final class ContainsNameQueryBuilderSpec extends ObjectBehavior |
23
|
|
|
{ |
24
|
|
|
function let( |
25
|
|
|
LocaleContextInterface $localeContext, |
26
|
|
|
ConcatedNameResolverInterface $productNameNameResolver |
27
|
|
|
): void { |
28
|
|
|
$this->beConstructedWith( |
29
|
|
|
$localeContext, |
30
|
|
|
$productNameNameResolver, |
31
|
|
|
'name_property' |
32
|
|
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function it_is_initializable(): void |
36
|
|
|
{ |
37
|
|
|
$this->shouldHaveType(ContainsNameQueryBuilder::class); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function it_implements_query_builder_interface(): void |
41
|
|
|
{ |
42
|
|
|
$this->shouldHaveType(QueryBuilderInterface::class); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function it_builds_query( |
46
|
|
|
LocaleContextInterface $localeContext, |
47
|
|
|
ConcatedNameResolverInterface $productNameNameResolver |
48
|
|
|
): void { |
49
|
|
|
$localeContext->getLocaleCode()->willReturn('en'); |
50
|
|
|
|
51
|
|
|
$productNameNameResolver->resolvePropertyName('en')->willReturn('en'); |
52
|
|
|
|
53
|
|
|
$this->buildQuery(['name_property' => 'Book'])->shouldBeAnInstanceOf(Match::class); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
function it_builds_returned_null_if_property_is_null( |
57
|
|
|
LocaleContextInterface $localeContext, |
58
|
|
|
ConcatedNameResolverInterface $productNameNameResolver |
59
|
|
|
): void { |
60
|
|
|
$localeContext->getLocaleCode()->willReturn('en'); |
61
|
|
|
|
62
|
|
|
$productNameNameResolver->resolvePropertyName('en')->willReturn('en'); |
63
|
|
|
|
64
|
|
|
$this->buildQuery(['name_property' => null])->shouldBeEqualTo(null); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|