| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the Sylius package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Paweł Jędrzejewski | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace spec\Sylius\Bundle\ResourceBundle\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PhpSpec\ObjectBehavior; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Prophecy\Argument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sylius\Bundle\ResourceBundle\Controller\Parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Sylius\Component\Resource\Metadata\MetadataInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Symfony\Component\HttpFoundation\ParameterBag; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Symfony\Component\HttpFoundation\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | final class RequestConfigurationSpec extends ObjectBehavior | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     function let(MetadataInterface $metadata, Request $request, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->beConstructedWith($metadata, $request, $parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     function it_has_request(Request $request): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->getRequest()->shouldReturn($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     function it_has_metadata(MetadataInterface $metadata): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->getMetadata()->shouldReturn($metadata); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     function it_has_parameters(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $this->getParameters()->shouldReturn($parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     function it_checks_if_its_a_html_request(Request $request): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $request->getRequestFormat()->willReturn('html'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $this->isHtmlRequest()->shouldReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $request->getRequestFormat()->willReturn('json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $this->isHtmlRequest()->shouldReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     function it_returns_default_template_names(MetadataInterface $metadata): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $metadata->getTemplatesNamespace()->willReturn('SyliusAdminBundle:Product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->getDefaultTemplate('index.html')->shouldReturn('SyliusAdminBundle:Product:index.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $this->getDefaultTemplate('show.html')->shouldReturn('SyliusAdminBundle:Product:show.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->getDefaultTemplate('create.html')->shouldReturn('SyliusAdminBundle:Product:create.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->getDefaultTemplate('update.html')->shouldReturn('SyliusAdminBundle:Product:update.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->getDefaultTemplate('custom.html')->shouldReturn('SyliusAdminBundle:Product:custom.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     function it_returns_default_template_names_for_a_directory_based_templates(MetadataInterface $metadata): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $metadata->getTemplatesNamespace()->willReturn('book/Backend'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->getDefaultTemplate('index.html')->shouldReturn('book/Backend/index.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $this->getDefaultTemplate('show.html')->shouldReturn('book/Backend/show.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->getDefaultTemplate('create.html')->shouldReturn('book/Backend/create.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $this->getDefaultTemplate('update.html')->shouldReturn('book/Backend/update.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $this->getDefaultTemplate('custom.html')->shouldReturn('book/Backend/custom.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     function it_takes_the_custom_template_if_specified(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $metadata->getTemplatesNamespace()->willReturn('SyliusAdminBundle:Product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $parameters->get('template', 'SyliusAdminBundle:Product:foo.html.twig')->willReturn('AppBundle:Product:show.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->getTemplate('foo.html')->shouldReturn('AppBundle:Product:show.html.twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     function it_gets_form_type_and_its_options(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $parameters->get('form')->willReturn(['type' => 'sylius_custom_resource']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $this->getFormType()->shouldReturn('sylius_custom_resource'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $this->getFormOptions()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $parameters->get('form')->willReturn('sylius_custom_resource'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $this->getFormType()->shouldReturn('sylius_custom_resource'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $this->getFormOptions()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $parameters->get('form')->willReturn(['type' => 'sylius_custom_resource', 'options' => ['key' => 'value']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $this->getFormType()->shouldReturn('sylius_custom_resource'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $this->getFormOptions()->shouldReturn(['key' => 'value']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $metadata->getClass('form')->willReturn('\Fully\Qualified\ClassName'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $parameters->get('form')->willReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $this->getFormType()->shouldReturn('\Fully\Qualified\ClassName'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $this->getFormOptions()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $metadata->getClass('form')->willReturn('\Fully\Qualified\ClassName'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $parameters->get('form')->willReturn(['options' => ['key' => 'value']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $this->getFormType()->shouldReturn('\Fully\Qualified\ClassName'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $this->getFormOptions()->shouldReturn(['key' => 'value']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     function it_generates_form_type_with_array_configuration(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         $metadata->getApplicationName()->willReturn('sylius'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $metadata->getName()->willReturn('product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $parameters->get('form')->willReturn(['type' => 'sylius_product', 'options' => ['validation_groups' => ['sylius']]]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $this->getFormType()->shouldReturn('sylius_product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $this->getFormOptions()->shouldReturn(['validation_groups' => ['sylius']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     function it_generates_route_names(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         $metadata->getApplicationName()->willReturn('sylius'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $metadata->getName()->willReturn('product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $parameters->get('section')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $this->getRouteName('index')->shouldReturn('sylius_product_index'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $this->getRouteName('show')->shouldReturn('sylius_product_show'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->getRouteName('custom')->shouldReturn('sylius_product_custom'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $parameters->get('section')->willReturn('admin'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $this->getRouteName('index')->shouldReturn('sylius_admin_product_index'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $this->getRouteName('show')->shouldReturn('sylius_admin_product_show'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $this->getRouteName('custom')->shouldReturn('sylius_admin_product_custom'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     function it_generates_redirect_referer(Parameters $parameters, Request $request, ParameterBag $bag): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         $request->headers = $bag; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $bag->get('referer')->willReturn('http://myurl.com'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $parameters->get('redirect')->willReturn(['referer' => 'http://myurl.com']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         $this->getRedirectReferer()->shouldReturn('http://myurl.com'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     function it_generates_redirect_route(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $metadata->getApplicationName()->willReturn('sylius'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         $metadata->getName()->willReturn('product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         $parameters->get('section')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         $parameters->get('redirect')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         $this->getRedirectRoute('index')->shouldReturn('sylius_product_index'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         $parameters->get('redirect')->willReturn(['route' => 'myRoute']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         $this->getRedirectRoute('show')->shouldReturn('myRoute'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         $parameters->get('redirect')->willReturn('myRoute'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         $this->getRedirectRoute('custom')->shouldReturn('myRoute'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     function it_takes_section_into_account_when_generating_redirect_route(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         $metadata->getApplicationName()->willReturn('sylius'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $metadata->getName()->willReturn('product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $parameters->get('section')->willReturn('admin'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $parameters->get('redirect')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         $this->getRedirectRoute('index')->shouldReturn('sylius_admin_product_index'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         $parameters->get('redirect')->willReturn(['route' => 'myRoute']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         $this->getRedirectRoute('show')->shouldReturn('myRoute'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         $parameters->get('redirect')->willReturn('myRoute'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         $this->getRedirectRoute('custom')->shouldReturn('myRoute'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     function it_returns_array_as_redirect_parameters(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $parameters->get('vars', [])->willReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $this->getVars()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $parameters->get('redirect')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         $this->getRedirectParameters()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         $parameters->get('redirect')->willReturn('string'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $this->getRedirectParameters()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $parameters->get('redirect')->willReturn(['parameters' => []]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $this->getRedirectParameters()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $parameters->get('redirect')->willReturn(['parameters' => ['myParameter']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $this->getRedirectParameters()->shouldReturn(['myParameter']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         $parameters->get('redirect')->willReturn(['parameters' => ['myParameter']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         $this->getRedirectParameters('resource')->shouldReturn(['myParameter']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         $invalidExtraParameters = ['redirect' => ['parameters' => 'myValue']]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $parameters->get('vars', [])->willReturn($invalidExtraParameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         $this->getVars()->shouldReturn($invalidExtraParameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $parameters->get('redirect')->willReturn(['parameters' => ['myParameter']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         $this->getRedirectParameters('resource')->shouldReturn(['myParameter']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         $validExtraParameters = ['redirect' => ['parameters' => ['myExtraParameter']]]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $parameters->get('vars', [])->willReturn($validExtraParameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         $this->getVars()->shouldReturn($validExtraParameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $parameters->get('redirect')->willReturn(['parameters' => ['myParameter']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         $this->getRedirectParameters('resource')->shouldReturn(['myParameter', 'myExtraParameter']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     function it_checks_if_limit_is_enabled(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         $parameters->get('limit', Argument::any())->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         $this->isLimited()->shouldReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         $parameters->get('limit', Argument::any())->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $this->isLimited()->shouldReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     function it_gets_limit(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $parameters->get('limit', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $parameters->get('limit', 10)->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $this->getLimit()->shouldReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         $parameters->get('limit', false)->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         $parameters->get('limit', 10)->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |         $this->getLimit()->shouldReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     function it_checks_if_pagination_is_enabled(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         $parameters->get('paginate', Argument::any())->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         $this->isPaginated()->shouldReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         $parameters->get('paginate', Argument::any())->willReturn(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         $this->isPaginated()->shouldReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $parameters->get('paginate', Argument::any())->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         $this->isPaginated()->shouldReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         $parameters->get('paginate', Argument::any())->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         $this->isPaginated()->shouldReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |     function it_gets_pagination_max_per_page(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         $parameters->get('paginate', 10)->willReturn(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         $this->getPaginationMaxPerPage()->shouldReturn(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         $parameters->get('paginate', 10)->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         $this->getPaginationMaxPerPage()->shouldReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     function it_checks_if_the_resource_is_filterable(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $parameters->get('filterable', Argument::any())->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         $this->isFilterable()->shouldReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         $parameters->get('filterable', Argument::any())->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |         $this->isFilterable()->shouldReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |     function it_has_no_filterable_parameter(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         $defaultCriteria = ['property' => 'myValue']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |         $parameters->get('criteria', Argument::any())->willReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |         $parameters->get('filterable', false)->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         $this->getCriteria($defaultCriteria)->shouldBeArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         $this->getCriteria($defaultCriteria)->shouldHaveCount(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |     function it_has_criteria_parameter(Parameters $parameters, Request $request): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         $criteria = ['property' => 'myNewValue']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         $parameters->get('filterable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         $parameters->get('criteria', Argument::any())->willReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         $request->get('criteria', [])->willReturn($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         $this->getCriteria()->shouldReturn($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     function it_allows_to_override_criteria_parameter_in_route(Parameters $parameters, Request $request): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |         $criteria = ['property' => 'myValue']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         $overriddenCriteria = ['other_property' => 'myNewValue']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         $combinedCriteria = ['property' => 'myValue', 'other_property' => 'myNewValue']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         $parameters->get('filterable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         $parameters->get('criteria', [])->willReturn($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |         $request->get('criteria', [])->willReturn($overriddenCriteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         $this->getCriteria()->shouldReturn($combinedCriteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         $defaultCriteria = ['slug' => 'foo']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         $combinedDefaultCriteria = ['property' => 'myValue', 'slug' => 'foo', 'other_property' => 'myNewValue']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         $parameters->get('filterable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         $parameters->get('criteria', Argument::any())->willReturn($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |         $request->get('criteria', [])->willReturn($overriddenCriteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |         $this->getCriteria($defaultCriteria)->shouldReturn($combinedDefaultCriteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |         $parameters->get('filterable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |         $parameters->get('criteria', [])->willReturn(['filter' => 'route']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |         $request->get('criteria', [])->willReturn(['filter' => 'request']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         $this->getCriteria(['filter' => 'default'])->shouldReturn(['filter' => 'request']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     function it_checks_if_the_resource_is_sortable(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         $parameters->get('sortable', Argument::any())->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         $this->isSortable()->shouldReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         $parameters->get('sortable', Argument::any())->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |         $this->isSortable()->shouldReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     function it_has_sorting_parameter(Parameters $parameters, Request $request): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         $sorting = ['property' => 'asc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |         $parameters->get('sortable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         $parameters->get('sorting', Argument::any())->willReturn($sorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         $request->get('sorting', [])->willReturn($sorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         $this->getSorting()->shouldReturn($sorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |     function it_has_no_sortable_parameter(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |         $defaultSorting = ['property' => 'desc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |         $parameters->get('sorting', Argument::any())->willReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |         $parameters->get('sortable', false)->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         $this->getSorting($defaultSorting)->shouldBeArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         $this->getSorting($defaultSorting)->shouldHaveCount(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |     function it_allows_to_override_sorting_parameter_in_route(Parameters $parameters, Request $request): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         $sorting = ['property' => 'desc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         $overriddenSorting = ['other_property' => 'asc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         $combinedSorting = ['other_property' => 'asc', 'property' => 'desc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         $parameters->get('sortable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         $parameters->get('sorting', [])->willReturn($sorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         $request->get('sorting', [])->willReturn($overriddenSorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |         $this->getSorting()->shouldReturn($combinedSorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $defaultSorting = ['foo' => 'bar']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |         $combinedDefaultSorting = ['other_property' => 'asc', 'property' => 'desc', 'foo' => 'bar']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         $parameters->get('sortable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |         $parameters->get('sorting', Argument::any())->willReturn($sorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         $request->get('sorting', [])->willReturn($overriddenSorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         $this->getSorting($defaultSorting)->shouldReturn($combinedDefaultSorting); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         $parameters->get('sortable', false)->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |         $parameters->get('sorting', [])->willReturn(['sort' => 'route']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |         $request->get('sorting', [])->willReturn(['sort' => 'request']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |         $this->getSorting(['sort' => 'default'])->shouldReturn(['sort' => 'request']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |     function it_has_repository_method_parameter(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |         $parameters->has('repository')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |         $this->getRepositoryMethod()->shouldReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         $parameters->has('repository')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         $parameters->get('repository')->willReturn(['method' => 'findAllEnabled']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |         $this->getRepositoryMethod()->shouldReturn('findAllEnabled'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |     function it_has_repository_arguments_parameter(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |         $parameters->has('repository')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         $this->getRepositoryArguments()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |         $repositoryConfiguration = ['arguments' => 'value']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |         $parameters->has('repository')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |         $parameters->get('repository')->willReturn($repositoryConfiguration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |         $this->getRepositoryArguments()->shouldReturn(['value']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         $repositoryConfiguration = ['arguments' => ['foo, bar']]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         $parameters->has('repository')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |         $parameters->get('repository')->willReturn($repositoryConfiguration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         $this->getRepositoryArguments()->shouldReturn(['foo, bar']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |     function it_has_factory_method_parameter(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         $parameters->has('factory')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         $this->getFactoryMethod()->shouldReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |         $parameters->has('factory')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |         $parameters->get('factory')->willReturn(['method' => 'createForPromotion']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |         $this->getFactoryMethod()->shouldReturn('createForPromotion'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |     function it_has_factory_arguments_parameter(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |         $parameters->has('factory')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |         $this->getFactoryArguments()->shouldReturn([]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         $factoryConfiguration = ['arguments' => 'value']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |         $parameters->has('factory')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         $parameters->get('factory')->willReturn($factoryConfiguration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |         $this->getFactoryArguments()->shouldReturn(['value']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |         $factoryConfiguration = ['arguments' => ['foo, bar']]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |         $parameters->has('factory')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         $parameters->get('factory')->willReturn($factoryConfiguration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $this->getFactoryArguments()->shouldReturn(['foo, bar']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |     function it_has_flash_message_parameter(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         $metadata->getApplicationName()->willReturn('sylius'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |         $metadata->getName()->willReturn('product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |         $parameters->get('flash', 'sylius.product.message')->willReturn('sylius.product.message'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         $this->getFlashMessage('message')->shouldReturn('sylius.product.message'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |         $parameters->get('flash', 'sylius.product.flash')->willReturn('sylius.product.myMessage'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |         $this->getFlashMessage('flash')->shouldReturn('sylius.product.myMessage'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |     function it_has_sortable_position_parameter(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |         $parameters->get('sortable_position', 'position')->willReturn('position'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |         $this->getSortablePosition()->shouldReturn('position'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |         $parameters->get('sortable_position', 'position')->willReturn('myPosition'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |         $this->getSortablePosition()->shouldReturn('myPosition'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |     function it_has_permission_unless_defined_as_false_in_parameters(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |         $parameters->get('permission', false)->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |         $this->shouldNotHavePermission(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         $parameters->get('permission', false)->willReturn('custom_permission'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         $this->shouldHavePermission(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |         $parameters->get('permission', false)->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |         $this->shouldNotHavePermission(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |     function it_generates_permission_name(MetadataInterface $metadata, Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |         $metadata->getApplicationName()->willReturn('sylius'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |         $metadata->getName()->willReturn('product'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |         $parameters->get('permission')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |         $this->getPermission('index')->shouldReturn('sylius.product.index'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |     function it_takes_permission_name_from_parameters_if_provided(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |         $parameters->get('permission')->willReturn('app.sales_order.view_pricing'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |         $this->getPermission('index')->shouldReturn('app.sales_order.view_pricing'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |     function it_throws_an_exception_when_permission_is_set_as_false_in_parameters_but_still_trying_to_get_it(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |         $parameters->get('permission')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |         $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |             ->shouldThrow(\LogicException::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |             ->during('getPermission', ['index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |     function it_has_event_name(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         $parameters->get('event')->willReturn('foo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |         $this->getEvent()->shouldReturn('foo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 495 |  |  |     function it_has_section(Parameters $parameters): void | 
            
                                                                        
                            
            
                                    
            
            
                | 496 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 497 |  |  |         $parameters->get('section')->willReturn(null); | 
            
                                                                        
                            
            
                                    
            
            
                | 498 |  |  |         $this->getSection()->shouldReturn(null); | 
            
                                                                        
                            
            
                                    
            
            
                | 499 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 500 |  |  |         $parameters->get('section')->willReturn('admin'); | 
            
                                                                        
                            
            
                                    
            
            
                | 501 |  |  |         $this->getSection()->shouldReturn('admin'); | 
            
                                                                        
                            
            
                                    
            
            
                | 502 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |     function it_has_vars(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         $parameters->get('vars', [])->willReturn(['foo' => 'bar']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |         $this->getVars()->shouldReturn(['foo' => 'bar']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |     function it_does_not_have_grid_unless_defined_as_in_parameters(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |         $parameters->has('grid')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |         $this->shouldNotHaveGrid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |         $parameters->has('grid')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         $this->shouldHaveGrid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |         $parameters->has('grid')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |         $parameters->get('grid')->willReturn('sylius_admin_tax_category'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |         $this->getGrid()->shouldReturn('sylius_admin_tax_category'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |     function it_throws_an_exception_when_trying_to_retrieve_undefined_grid(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |         $parameters->has('grid')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |         $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |             ->shouldThrow(\LogicException::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             ->during('getGrid') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |     function it_can_have_state_machine_transition(Parameters $parameters): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |         $parameters->has('state_machine')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |         $this->hasStateMachine()->shouldReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |         $parameters->has('state_machine')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |         $parameters->get('state_machine')->willReturn([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |             'graph' => 'sylius_product_review_state', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |             'transition' => 'approve', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |         $this->hasStateMachine()->shouldReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |         $this->getStateMachineGraph()->shouldReturn('sylius_product_review_state'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |         $this->getStateMachineTransition()->shouldReturn('approve'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 549 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 550 |  |  |  |