Passed
Push — master ( cc4e78...1262d4 )
by Damian
04:08
created

spec/Facet/OptionFacetSpec.php (6 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\BitBag\SyliusElasticsearchPlugin\Facet;
6
7
use BitBag\SyliusElasticsearchPlugin\Facet\FacetInterface;
8
use BitBag\SyliusElasticsearchPlugin\Facet\OptionFacet;
9
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
10
use Elastica\Aggregation\Terms;
11
use PhpSpec\ObjectBehavior;
12
use Sylius\Component\Product\Model\ProductOption;
13
use Sylius\Component\Resource\Repository\RepositoryInterface;
14
15
final class OptionFacetSpec extends ObjectBehavior
16
{
17
    function let(ConcatedNameResolverInterface $optionNameResolver, RepositoryInterface $productOptionRepository): void
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
    {
19
        $optionCode = 'SUPPLY';
20
        $optionNameResolver->resolvePropertyName('SUPPLY')->willReturn('option_SUPPLY');
21
        $productOption = new ProductOption();
22
        $productOption->setCurrentLocale('en_US');
23
        $productOption->setName('Supply');
24
        $productOptionRepository->findOneBy(['code' => 'SUPPLY'])->willReturn($productOption);
25
        $this->beConstructedWith($optionNameResolver, $productOptionRepository, $optionCode);
26
    }
27
28
    function it_is_initializable(): void
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
29
    {
30
        $this->shouldHaveType(OptionFacet::class);
31
    }
32
33
    function it_implements_facet_interface(): void
34
    {
35
        $this->shouldHaveType(FacetInterface::class);
36
    }
37
38
    function it_returns_terms_aggregation(): void
39
    {
40
        $expectedAggregation = new Terms('');
41
        $expectedAggregation->setField('option_SUPPLY.keyword');
42
43
        $this->getAggregation()->shouldBeLike($expectedAggregation);
0 ignored issues
show
The method getAggregation() does not exist on spec\BitBag\SyliusElasti...n\Facet\OptionFacetSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $this->/** @scrutinizer ignore-call */ 
44
               getAggregation()->shouldBeLike($expectedAggregation);
Loading history...
44
    }
45
46
    function it_returns_terms_query(): void
47
    {
48
        $expectedQuery = new \Elastica\Query\Terms('option_SUPPLY.keyword', ['selected', 'values']);
49
50
        $this->getQuery(['selected', 'values'])->shouldBeLike($expectedQuery);
0 ignored issues
show
The method getQuery() does not exist on spec\BitBag\SyliusElasti...n\Facet\OptionFacetSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
        $this->/** @scrutinizer ignore-call */ 
51
               getQuery(['selected', 'values'])->shouldBeLike($expectedQuery);
Loading history...
51
    }
52
53
    function it_returns_bucket_label(): void
54
    {
55
        $this->getBucketLabel(['key' => 'option_value', 'doc_count' => 3])->shouldReturn('Option Value (3)');
0 ignored issues
show
The method getBucketLabel() does not exist on spec\BitBag\SyliusElasti...n\Facet\OptionFacetSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        $this->/** @scrutinizer ignore-call */ 
56
               getBucketLabel(['key' => 'option_value', 'doc_count' => 3])->shouldReturn('Option Value (3)');
Loading history...
56
    }
57
58
    function it_returns_option_name_as_facet_label(): void
59
    {
60
        $this->getLabel()->shouldReturn('Supply');
0 ignored issues
show
The method getLabel() does not exist on spec\BitBag\SyliusElasti...n\Facet\OptionFacetSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
        $this->/** @scrutinizer ignore-call */ 
61
               getLabel()->shouldReturn('Supply');
Loading history...
61
    }
62
}
63