@@ -168,6 +168,208 @@ function it_generates_routing_based_on_resource_configuration(
168168 $ this ->load ($ configuration , 'sylius.resource ' )->shouldReturn ($ routeCollection );
169169 }
170170
171+ function it_generates_new_routing_paths_if_bc_layer_is_disabled (
172+ RegistryInterface $ resourceRegistry ,
173+ MetadataInterface $ metadata ,
174+ RouteFactoryInterface $ routeFactory ,
175+ RouteCollection $ routeCollection ,
176+ Route $ showRoute ,
177+ Route $ indexRoute ,
178+ Route $ createRoute ,
179+ Route $ updateRoute ,
180+ Route $ bulkDeleteRoute ,
181+ Route $ deleteRoute ,
182+ ): void {
183+ $ this ->beConstructedWith ($ resourceRegistry , $ routeFactory , null , false );
184+
185+ $ resourceRegistry ->get ('sylius.product ' )->willReturn ($ metadata );
186+ $ metadata ->getApplicationName ()->willReturn ('sylius ' );
187+ $ metadata ->getName ()->willReturn ('product ' );
188+ $ metadata ->getPluralName ()->willReturn ('products ' );
189+ $ metadata ->getServiceId ('controller ' )->willReturn ('sylius.controller.product ' );
190+
191+ $ routeFactory ->createRouteCollection ()->willReturn ($ routeCollection );
192+
193+ $ configuration =
194+ <<<EOT
195+ alias: sylius.product
196+ EOT ;
197+
198+ $ showDefaults = [
199+ '_controller ' => 'sylius.controller.product::showAction ' ,
200+ '_sylius ' => [
201+ 'permission ' => false ,
202+ ],
203+ ];
204+ $ routeFactory
205+ ->createRoute ('/products/{id} ' , $ showDefaults , [], [], '' , [], ['GET ' ], '' )
206+ ->willReturn ($ showRoute )
207+ ;
208+ $ routeCollection ->add ('sylius_product_show ' , $ showRoute )->shouldBeCalled ();
209+
210+ $ indexDefaults = [
211+ '_controller ' => 'sylius.controller.product::indexAction ' ,
212+ '_sylius ' => [
213+ 'permission ' => false ,
214+ ],
215+ ];
216+ $ routeFactory
217+ ->createRoute ('/products ' , $ indexDefaults , [], [], '' , [], ['GET ' ], '' )
218+ ->willReturn ($ indexRoute )
219+ ;
220+ $ routeCollection ->add ('sylius_product_index ' , $ indexRoute )->shouldBeCalled ();
221+
222+ $ createDefaults = [
223+ '_controller ' => 'sylius.controller.product::createAction ' ,
224+ '_sylius ' => [
225+ 'permission ' => false ,
226+ ],
227+ ];
228+ $ routeFactory
229+ ->createRoute ('/products/new ' , $ createDefaults , [], [], '' , [], ['GET ' , 'POST ' ], '' )
230+ ->willReturn ($ createRoute )
231+ ;
232+ $ routeCollection ->add ('sylius_product_create ' , $ createRoute )->shouldBeCalled ();
233+
234+ $ updateDefaults = [
235+ '_controller ' => 'sylius.controller.product::updateAction ' ,
236+ '_sylius ' => [
237+ 'permission ' => false ,
238+ ],
239+ ];
240+ $ routeFactory
241+ ->createRoute ('/products/{id}/edit ' , $ updateDefaults , [], [], '' , [], ['GET ' , 'PUT ' , 'PATCH ' , 'POST ' ], '' )
242+ ->willReturn ($ updateRoute )
243+ ;
244+ $ routeCollection ->add ('sylius_product_update ' , $ updateRoute )->shouldBeCalled ();
245+
246+ $ bulkDeleteDefaults = [
247+ '_controller ' => 'sylius.controller.product::bulkDeleteAction ' ,
248+ '_sylius ' => [
249+ 'permission ' => false ,
250+ 'paginate ' => false ,
251+ 'repository ' => [
252+ 'method ' => 'findById ' ,
253+ 'arguments ' => ['$ids ' ],
254+ ],
255+ ],
256+ ];
257+ $ routeFactory
258+ ->createRoute ('/products/bulk_delete ' , $ bulkDeleteDefaults , [], [], '' , [], ['DELETE ' , 'POST ' ], '' )
259+ ->willReturn ($ bulkDeleteRoute )
260+ ;
261+ $ routeCollection ->add ('sylius_product_bulk_delete ' , $ bulkDeleteRoute )->shouldBeCalled ();
262+
263+ $ deleteDefaults = [
264+ '_controller ' => 'sylius.controller.product::deleteAction ' ,
265+ '_sylius ' => [
266+ 'permission ' => false ,
267+ ],
268+ ];
269+ $ routeFactory
270+ ->createRoute ('/products/{id}/delete ' , $ deleteDefaults , [], [], '' , [], ['DELETE ' , 'POST ' ], '' )
271+ ->willReturn ($ deleteRoute )
272+ ;
273+ $ routeCollection ->add ('sylius_product_delete ' , $ deleteRoute )->shouldBeCalled ();
274+
275+ $ this ->load ($ configuration , 'sylius.resource ' )->shouldReturn ($ routeCollection );
276+ }
277+
278+ function it_generates_new_api_routing_paths_if_bc_layer_is_disabled (
279+ RegistryInterface $ resourceRegistry ,
280+ MetadataInterface $ metadata ,
281+ RouteFactoryInterface $ routeFactory ,
282+ RouteCollection $ routeCollection ,
283+ Route $ showRoute ,
284+ Route $ indexRoute ,
285+ Route $ createRoute ,
286+ Route $ updateRoute ,
287+ Route $ bulkDeleteRoute ,
288+ Route $ deleteRoute ,
289+ ): void {
290+ $ this ->beConstructedWith ($ resourceRegistry , $ routeFactory , null , false );
291+
292+ $ resourceRegistry ->get ('sylius.product ' )->willReturn ($ metadata );
293+ $ metadata ->getApplicationName ()->willReturn ('sylius ' );
294+ $ metadata ->getName ()->willReturn ('product ' );
295+ $ metadata ->getPluralName ()->willReturn ('products ' );
296+ $ metadata ->getServiceId ('controller ' )->willReturn ('sylius.controller.product ' );
297+
298+ $ routeFactory ->createRouteCollection ()->willReturn ($ routeCollection );
299+
300+ $ configuration =
301+ <<<EOT
302+ alias: sylius.product
303+ EOT ;
304+
305+ $ showDefaults = [
306+ '_controller ' => 'sylius.controller.product::showAction ' ,
307+ '_sylius ' => [
308+ 'permission ' => false ,
309+ 'serialization_groups ' => ['Default ' , 'Detailed ' ],
310+ ],
311+ ];
312+ $ routeFactory
313+ ->createRoute ('/products/{id} ' , $ showDefaults , [], [], '' , [], ['GET ' ], '' )
314+ ->willReturn ($ showRoute )
315+ ;
316+ $ routeCollection ->add ('sylius_product_show ' , $ showRoute )->shouldBeCalled ();
317+
318+ $ indexDefaults = [
319+ '_controller ' => 'sylius.controller.product::indexAction ' ,
320+ '_sylius ' => [
321+ 'permission ' => false ,
322+ 'serialization_groups ' => ['Default ' ],
323+ ],
324+ ];
325+ $ routeFactory
326+ ->createRoute ('/products ' , $ indexDefaults , [], [], '' , [], ['GET ' ], '' )
327+ ->willReturn ($ indexRoute )
328+ ;
329+ $ routeCollection ->add ('sylius_product_index ' , $ indexRoute )->shouldBeCalled ();
330+
331+ $ createDefaults = [
332+ '_controller ' => 'sylius.controller.product::createAction ' ,
333+ '_sylius ' => [
334+ 'permission ' => false ,
335+ 'serialization_groups ' => ['Default ' , 'Detailed ' ],
336+ ],
337+ ];
338+ $ routeFactory
339+ ->createRoute ('/products ' , $ createDefaults , [], [], '' , [], ['POST ' ], '' )
340+ ->willReturn ($ createRoute )
341+ ;
342+ $ routeCollection ->add ('sylius_product_create ' , $ createRoute )->shouldBeCalled ();
343+
344+ $ updateDefaults = [
345+ '_controller ' => 'sylius.controller.product::updateAction ' ,
346+ '_sylius ' => [
347+ 'permission ' => false ,
348+ 'serialization_groups ' => ['Default ' , 'Detailed ' ],
349+ ],
350+ ];
351+ $ routeFactory
352+ ->createRoute ('/products/{id} ' , $ updateDefaults , [], [], '' , [], ['PUT ' , 'PATCH ' ], '' )
353+ ->willReturn ($ updateRoute )
354+ ;
355+ $ routeCollection ->add ('sylius_product_update ' , $ updateRoute )->shouldBeCalled ();
356+
357+ $ deleteDefaults = [
358+ '_controller ' => 'sylius.controller.product::deleteAction ' ,
359+ '_sylius ' => [
360+ 'permission ' => false ,
361+ 'csrf_protection ' => false ,
362+ ],
363+ ];
364+ $ routeFactory
365+ ->createRoute ('/products/{id} ' , $ deleteDefaults , [], [], '' , [], ['DELETE ' ], '' )
366+ ->willReturn ($ deleteRoute )
367+ ;
368+ $ routeCollection ->add ('sylius_product_delete ' , $ deleteRoute )->shouldBeCalled ();
369+
370+ $ this ->load ($ configuration , 'sylius.resource_api ' )->shouldReturn ($ routeCollection );
371+ }
372+
171373 function it_generates_urlized_paths_for_resources_with_multiple_words_in_name (
172374 RegistryInterface $ resourceRegistry ,
173375 MetadataInterface $ metadata ,
0 commit comments