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\Action\Shop; |
||||
14 | |||||
15 | use BitBag\SyliusElasticsearchPlugin\Controller\Action\Shop\ListProductsAction; |
||||
16 | use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\DataHandlerInterface; |
||||
17 | use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\PaginationDataHandlerInterface; |
||||
18 | use BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler\SortDataHandlerInterface; |
||||
19 | use BitBag\SyliusElasticsearchPlugin\Finder\ShopProductsFinderInterface; |
||||
20 | use BitBag\SyliusElasticsearchPlugin\Form\Type\ShopProductsFilterType; |
||||
21 | use Pagerfanta\Pagerfanta; |
||||
22 | use PhpSpec\ObjectBehavior; |
||||
23 | use Prophecy\Argument; |
||||
24 | use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
||||
25 | use Symfony\Component\Form\FormFactoryInterface; |
||||
26 | use Symfony\Component\Form\FormInterface; |
||||
27 | use Symfony\Component\Form\FormView; |
||||
28 | use Symfony\Component\HttpFoundation\ParameterBag; |
||||
29 | use Symfony\Component\HttpFoundation\Request; |
||||
30 | use Symfony\Component\HttpFoundation\Response; |
||||
31 | |||||
32 | final class ListProductsActionSpec extends ObjectBehavior |
||||
33 | { |
||||
34 | function let( |
||||
0 ignored issues
–
show
|
|||||
35 | FormFactoryInterface $formFactory, |
||||
36 | DataHandlerInterface $shopProductListDataHandler, |
||||
37 | SortDataHandlerInterface $shopProductsSortDataHandler, |
||||
38 | PaginationDataHandlerInterface $paginationDataHandler, |
||||
39 | ShopProductsFinderInterface $shopProductsFinder, |
||||
40 | EngineInterface $templatingEngine |
||||
41 | ): void { |
||||
42 | $this->beConstructedWith( |
||||
43 | $formFactory, |
||||
44 | $shopProductListDataHandler, |
||||
45 | $shopProductsSortDataHandler, |
||||
46 | $paginationDataHandler, |
||||
47 | $shopProductsFinder, |
||||
48 | $templatingEngine |
||||
49 | ); |
||||
50 | } |
||||
51 | |||||
52 | function it_is_initializable(): void |
||||
0 ignored issues
–
show
|
|||||
53 | { |
||||
54 | $this->shouldHaveType(ListProductsAction::class); |
||||
55 | } |
||||
56 | |||||
57 | function it_renders_product_list( |
||||
58 | Request $request, |
||||
59 | FormFactoryInterface $formFactory, |
||||
60 | FormInterface $form, |
||||
61 | ParameterBag $queryParameters, |
||||
62 | DataHandlerInterface $shopProductListDataHandler, |
||||
63 | SortDataHandlerInterface $shopProductsSortDataHandler, |
||||
64 | PaginationDataHandlerInterface $paginationDataHandler, |
||||
65 | ShopProductsFinderInterface $shopProductsFinder, |
||||
66 | Pagerfanta $pagerfanta, |
||||
67 | FormView $formView, |
||||
68 | EngineInterface $templatingEngine, |
||||
69 | Response $response |
||||
70 | ): void { |
||||
71 | $form->getData()->willReturn([]); |
||||
72 | $form->handleRequest($request)->shouldBeCalled(); |
||||
73 | $form->createView()->willReturn($formView); |
||||
74 | |||||
75 | $formFactory->createNamed(null, ShopProductsFilterType::class)->willReturn($form); |
||||
76 | |||||
77 | $request->query = $queryParameters; |
||||
78 | $queryParameters->all()->willReturn([]); |
||||
79 | |||||
80 | $request->get('template')->willReturn('@Template'); |
||||
81 | $request->get('slug')->willReturn(null); |
||||
82 | |||||
83 | $shopProductListDataHandler->retrieveData(['slug' => null])->willReturn(['taxon' => null]); |
||||
84 | $shopProductsSortDataHandler->retrieveData(['slug' => null]); |
||||
85 | $paginationDataHandler->retrieveData(['slug' => null]); |
||||
86 | |||||
87 | $shopProductsFinder->find(['taxon' => null])->willReturn($pagerfanta); |
||||
88 | |||||
89 | $templatingEngine->renderResponse('@Template', Argument::any())->willReturn($response); |
||||
0 ignored issues
–
show
Prophecy\Argument::any() of type Prophecy\Argument\Token\AnyValueToken is incompatible with the type array expected by parameter $parameters of Symfony\Bundle\Framework...rface::renderResponse() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
90 | |||||
91 | $this->__invoke($request); |
||||
92 | } |
||||
93 | } |
||||
94 |
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.