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