17
17
use ApiPlatform \Core \Api \OperationMethodResolverInterface ;
18
18
use ApiPlatform \Core \Api \ResourceClassResolverInterface ;
19
19
use ApiPlatform \Core \Api \UrlGeneratorInterface ;
20
+ use ApiPlatform \Core \Bridge \Symfony \Routing \RouterOperationPathResolver ;
20
21
use ApiPlatform \Core \Documentation \Documentation ;
21
22
use ApiPlatform \Core \Metadata \Property \Factory \PropertyMetadataFactoryInterface ;
22
23
use ApiPlatform \Core \Metadata \Property \Factory \PropertyNameCollectionFactoryInterface ;
41
42
use Prophecy \Argument ;
42
43
use Psr \Container \ContainerInterface ;
43
44
use Symfony \Component \PropertyInfo \Type ;
45
+ use Symfony \Component \Routing \Route ;
46
+ use Symfony \Component \Routing \RouteCollection ;
47
+ use Symfony \Component \Routing \RouterInterface ;
44
48
use Symfony \Component \Serializer \NameConverter \NameConverterInterface ;
45
49
46
50
/**
@@ -1507,7 +1511,14 @@ public function testNormalizeWithSubResource()
1507
1511
$ operationMethodResolverProphecy = $ this ->prophesize (OperationMethodResolverInterface::class);
1508
1512
$ operationMethodResolverProphecy ->getItemOperationMethod (Question::class, 'get ' )->shouldBeCalled ()->willReturn ('GET ' );
1509
1513
1510
- $ operationPathResolver = new CustomOperationPathResolver (new OperationPathResolver (new UnderscorePathSegmentNameGenerator ()));
1514
+ $ routeCollection = new RouteCollection ();
1515
+ $ routeCollection ->add ('api_questions_answer_get_subresource ' , new Route ('/api/questions/{id}/answer.{_format} ' ));
1516
+ $ routeCollection ->add ('api_questions_get_item ' , new Route ('/api/questions/{id}.{_format} ' ));
1517
+
1518
+ $ routerProphecy = $ this ->prophesize (RouterInterface::class);
1519
+ $ routerProphecy ->getRouteCollection ()->shouldBeCalled ()->willReturn ($ routeCollection );
1520
+
1521
+ $ operationPathResolver = new RouterOperationPathResolver ($ routerProphecy ->reveal (), new CustomOperationPathResolver (new OperationPathResolver (new UnderscorePathSegmentNameGenerator ())));
1511
1522
1512
1523
$ resourceMetadataFactory = $ resourceMetadataFactoryProphecy ->reveal ();
1513
1524
$ propertyNameCollectionFactory = $ propertyNameCollectionFactoryProphecy ->reveal ();
@@ -1535,7 +1546,7 @@ public function testNormalizeWithSubResource()
1535
1546
'version ' => '1.2.3 ' ,
1536
1547
],
1537
1548
'paths ' => new \ArrayObject ([
1538
- '/questions/{id} ' => [
1549
+ '/api/ questions/{id} ' => [
1539
1550
'get ' => new \ArrayObject ([
1540
1551
'tags ' => ['Question ' ],
1541
1552
'operationId ' => 'getQuestionItem ' ,
@@ -1558,7 +1569,7 @@ public function testNormalizeWithSubResource()
1558
1569
],
1559
1570
]),
1560
1571
],
1561
- '/questions/{id}/answer ' => new \ArrayObject ([
1572
+ '/api/ questions/{id}/answer ' => new \ArrayObject ([
1562
1573
'get ' => new \ArrayObject ([
1563
1574
'tags ' => ['Answer ' , 'Question ' ],
1564
1575
'operationId ' => 'ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Question-answer-ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Answer ' ,
0 commit comments