1515
1616use ApiPlatform \Symfony \Bundle \Test \ApiTestCase ;
1717use ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \Issue7469TestResource ;
18+ use ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \Issue7939BarResource ;
19+ use ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \Issue7939BazResource ;
20+ use ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \Issue7939FooResource ;
1821use ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \LinkParameterProviderResource ;
1922use ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \WithParameter ;
2023use ApiPlatform \Tests \Fixtures \TestBundle \Entity \Company ;
@@ -40,7 +43,7 @@ final class LinkProviderParameterTest extends ApiTestCase
4043 */
4144 public static function getResources (): array
4245 {
43- return [WithParameter::class, Dummy::class, Employee::class, Company::class, LinkParameterProviderResource::class, Issue7469TestResource::class, Issue7469Dummy::class, Pairing::class, Plan::class];
46+ return [WithParameter::class, Dummy::class, Employee::class, Company::class, LinkParameterProviderResource::class, Issue7469TestResource::class, Issue7469Dummy::class, Pairing::class, Plan::class, Issue7939FooResource::class, Issue7939BarResource::class, Issue7939BazResource::class ];
4447 }
4548
4649 /**
@@ -236,6 +239,47 @@ public function testSecurityLinkWithDifferentFromClassDoesNotBreakDoctrine(): vo
236239 ]);
237240 }
238241
242+ /**
243+ * @see https://github.com/api-platform/core/issues/7939
244+ */
245+ public function testReadLinkParameterProviderResolvesNestedUriVariables (): void
246+ {
247+ $ container = static ::getContainer ();
248+ if ('mongodb ' === $ container ->getParameter ('kernel.environment ' )) {
249+ $ this ->markTestSkipped ();
250+ }
251+
252+ $ response = self ::createClient ()->request ('GET ' , '/issue7939_foos/F/bars/B/baz ' );
253+ self ::assertResponseStatusCodeSame (200 );
254+ self ::assertJsonContains ([
255+ 'fooId ' => 'F ' ,
256+ 'barId ' => 'B ' ,
257+ ]);
258+ }
259+
260+ /**
261+ * @see https://github.com/api-platform/core/issues/7939
262+ */
263+ public function testParentLinkProviderEnforcesParentScope (): void
264+ {
265+ $ container = static ::getContainer ();
266+ if ('mongodb ' === $ container ->getParameter ('kernel.environment ' )) {
267+ $ this ->markTestSkipped ();
268+ }
269+
270+ $ client = self ::createClient ();
271+
272+ $ client ->request ('GET ' , '/issue7939_foos/F2/bars/B/baz_strict ' );
273+ self ::assertResponseStatusCodeSame (200 );
274+ self ::assertJsonContains ([
275+ 'fooId ' => 'F2 ' ,
276+ 'barId ' => 'B ' ,
277+ ]);
278+
279+ $ client ->request ('GET ' , '/issue7939_foos/F1/bars/B/baz_strict ' );
280+ self ::assertResponseStatusCodeSame (404 );
281+ }
282+
239283 public function testIssue7469IriGenerationFailsForLinkedResource (): void
240284 {
241285 $ container = static ::getContainer ();
0 commit comments