@@ -187,6 +187,27 @@ public function testGetRouteNameForCollectionRoute()
187187 $ this ->assertSame ('some_collection_route ' , $ actual );
188188 }
189189
190+ public function testGetRouteNameForCollectionRouteFromAbstract ()
191+ {
192+ $ routeCollection = new RouteCollection ();
193+ $ routeCollection ->add ('some_item_route ' , new Route ('/some/item/path/{id} ' , [
194+ '_api_resource_class ' => BaseUser::class,
195+ '_api_item_operation_name ' => 'some_item_op ' ,
196+ ]));
197+ $ routeCollection ->add ('some_collection_route ' , new Route ('/some/collection/path ' , [
198+ '_api_resource_class ' => BaseUser::class,
199+ '_api_collection_operation_name ' => 'some_collection_op ' ,
200+ ]));
201+
202+ $ routerProphecy = $ this ->prophesize (RouterInterface::class);
203+ $ routerProphecy ->getRouteCollection ()->willReturn ($ routeCollection );
204+
205+ $ routeNameResolver = new RouteNameResolver ($ routerProphecy ->reveal ());
206+ $ actual = $ routeNameResolver ->getRouteName (User::class, OperationType::COLLECTION );
207+
208+ $ this ->assertSame ('some_collection_route ' , $ actual );
209+ }
210+
190211 public function testGetRouteNameForSubresourceRoute ()
191212 {
192213 $ routeCollection = new RouteCollection ();
@@ -213,4 +234,31 @@ public function testGetRouteNameForSubresourceRoute()
213234
214235 $ this ->assertSame ('b_some_subresource_route ' , $ actual );
215236 }
237+
238+ public function testGetRouteNameForSubresourceRouteFromAbstract ()
239+ {
240+ $ routeCollection = new RouteCollection ();
241+ $ routeCollection ->add ('a_some_subresource_route ' , new Route ('/a/some/item/path/{id} ' , [
242+ '_api_resource_class ' => BaseUser::class,
243+ '_api_subresource_operation_name ' => 'some_other_item_op ' ,
244+ '_api_subresource_context ' => ['identifiers ' => [[1 , 'bar ' ]]],
245+ ]));
246+ $ routeCollection ->add ('b_some_subresource_route ' , new Route ('/b/some/item/path/{id} ' , [
247+ '_api_resource_class ' => BaseUser::class,
248+ '_api_subresource_operation_name ' => 'some_item_op ' ,
249+ '_api_subresource_context ' => ['identifiers ' => [[1 , 'foo ' ]]],
250+ ]));
251+ $ routeCollection ->add ('some_collection_route ' , new Route ('/some/collection/path ' , [
252+ '_api_resource_class ' => BaseUser::class,
253+ '_api_collection_operation_name ' => 'some_collection_op ' ,
254+ ]));
255+
256+ $ routerProphecy = $ this ->prophesize (RouterInterface::class);
257+ $ routerProphecy ->getRouteCollection ()->willReturn ($ routeCollection );
258+
259+ $ routeNameResolver = new RouteNameResolver ($ routerProphecy ->reveal ());
260+ $ actual = $ routeNameResolver ->getRouteName (User::class, OperationType::SUBRESOURCE , ['subresource_resources ' => ['foo ' => 1 ]]);
261+
262+ $ this ->assertSame ('b_some_subresource_route ' , $ actual );
263+ }
216264}
0 commit comments