|
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\Finder; |
|
14
|
|
|
|
|
15
|
|
|
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinder; |
|
16
|
|
|
use BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinderInterface; |
|
17
|
|
|
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface; |
|
18
|
|
|
use Elastica\Query\AbstractQuery; |
|
19
|
|
|
use FOS\ElasticaBundle\Finder\FinderInterface; |
|
20
|
|
|
use PhpSpec\ObjectBehavior; |
|
21
|
|
|
use Sylius\Component\Core\Model\TaxonInterface; |
|
22
|
|
|
|
|
23
|
|
|
final class ProductAttributesFinderSpec extends ObjectBehavior |
|
24
|
|
|
{ |
|
25
|
|
|
function let( |
|
|
|
|
|
|
26
|
|
|
FinderInterface $attributesFinder, |
|
27
|
|
|
QueryBuilderInterface $attributesByTaxonQueryBuilder |
|
28
|
|
|
): void { |
|
29
|
|
|
$this->beConstructedWith( |
|
30
|
|
|
$attributesFinder, |
|
31
|
|
|
$attributesByTaxonQueryBuilder, |
|
32
|
|
|
'taxons' |
|
33
|
|
|
); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function it_is_initializable(): void |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
$this->shouldHaveType(ProductAttributesFinder::class); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_implements_product_attributes_finder_interface(): void |
|
42
|
|
|
{ |
|
43
|
|
|
$this->shouldHaveType(ProductAttributesFinderInterface::class); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function it_finds_by_taxon( |
|
47
|
|
|
TaxonInterface $taxon, |
|
48
|
|
|
QueryBuilderInterface $attributesByTaxonQueryBuilder, |
|
49
|
|
|
FinderInterface $attributesFinder, |
|
50
|
|
|
AbstractQuery $query |
|
51
|
|
|
): void { |
|
52
|
|
|
$taxon->getCode()->willReturn('book'); |
|
53
|
|
|
|
|
54
|
|
|
$attributesByTaxonQueryBuilder->buildQuery(['taxons' => 'book'])->willReturn($query); |
|
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
$attributesFinder->find($query)->willReturn([]); |
|
57
|
|
|
|
|
58
|
|
|
$this->findByTaxon($taxon)->shouldBeEqualTo([]); |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
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.