Completed
Push — master ( b40331...4f0c8d )
by Damian
14:06 queued 09:46
created

ShopProductsSortDataHandlerSpec.php (2 issues)

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\Controller\RequestDataHandler;
14
15
use BitBag\SyliusElasticsearchPlugin\Context\TaxonContextInterface;
16
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\ShopProductsSortDataHandler;
17
use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\SortDataHandlerInterface;
18
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
19
use PhpSpec\ObjectBehavior;
20
use Sylius\Component\Channel\Context\ChannelContextInterface;
21
use Sylius\Component\Core\Model\TaxonInterface;
22
23
final class ShopProductsSortDataHandlerSpec extends ObjectBehavior
24
{
25
    function let(
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...
26
        ConcatedNameResolverInterface $channelPricingNameResolver,
27
        ChannelContextInterface $channelContext,
28
        TaxonContextInterface $taxonContext,
29
        ConcatedNameResolverInterface $taxonPositionNameResolver
30
    ): void {
31
        $this->beConstructedWith(
32
            $channelPricingNameResolver,
33
            $channelContext,
34
            $taxonContext,
35
            $taxonPositionNameResolver,
36
            'sold_units',
37
            'created_at',
38
            'price'
39
        );
40
    }
41
42
    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...
43
    {
44
        $this->shouldHaveType(ShopProductsSortDataHandler::class);
45
    }
46
47
    function it_implements_sort_data_handler_interface(): void
48
    {
49
        $this->shouldHaveType(SortDataHandlerInterface::class);
50
    }
51
52
    function it_retrieves_data(
53
        TaxonContextInterface $taxonContext,
54
        TaxonInterface $taxon,
55
        ConcatedNameResolverInterface $taxonPositionNameResolver
56
    ): void
57
    {
58
        $taxonContext->getTaxon()->willReturn($taxon);
59
        $taxon->getCode()->willReturn('t_shirt');
60
        $taxonPositionNameResolver->resolvePropertyName('t_shirt')->willReturn('taxon_position_t_shirts');
61
62
        $this->retrieveData([])->shouldBeEqualTo([
63
            'sort' => [
64
                'taxon_position_t_shirts' => [
65
                    'order' => SortDataHandlerInterface::SORT_ASC_INDEX,
66
                    'unmapped_type' => 'keyword',
67
                ],
68
            ],
69
        ]);
70
    }
71
}
72