@@ -298,6 +298,7 @@ public function testExpressionFailureReturns404()
298298
299299 $ manager ->expects ($ this ->once ())
300300 ->method ('getRepository ' )
301+ ->with (\stdClass::class)
301302 ->willReturn ($ repository );
302303
303304 $ language ->expects ($ this ->once ())
@@ -329,6 +330,7 @@ public function testExpressionMapsToArgument()
329330
330331 $ manager ->expects ($ this ->once ())
331332 ->method ('getRepository ' )
333+ ->with (\stdClass::class)
332334 ->willReturn ($ repository );
333335
334336 $ language ->expects ($ this ->once ())
@@ -343,6 +345,48 @@ public function testExpressionMapsToArgument()
343345 $ this ->assertSame ([$ object ], $ resolver ->resolve ($ request , $ argument ));
344346 }
345347
348+ public function testExpressionMapsToIterableArgument ()
349+ {
350+ $ manager = $ this ->createMock (ObjectManager::class);
351+ $ registry = $ this ->createRegistry ($ manager );
352+ $ language = $ this ->createMock (ExpressionLanguage::class);
353+ $ resolver = new EntityValueResolver ($ registry , $ language );
354+
355+ $ request = new Request ();
356+ $ request ->attributes ->set ('id ' , 5 );
357+ $ request ->query ->set ('sort ' , 'ASC ' );
358+ $ request ->query ->set ('limit ' , 10 );
359+ $ argument = $ this ->createArgument (
360+ 'iterable ' ,
361+ new MapEntity (
362+ class: \stdClass::class,
363+ expr: $ expr = 'repository.findBy({"author": id}, {"createdAt": request.query.get("sort", "DESC")}, request.query.getInt("limit", 10)) ' ,
364+ ),
365+ 'arg1 ' ,
366+ );
367+
368+ $ repository = $ this ->createMock (ObjectRepository::class);
369+ // find should not be attempted on this repository as a fallback
370+ $ repository ->expects ($ this ->never ())
371+ ->method ('find ' );
372+
373+ $ manager ->expects ($ this ->once ())
374+ ->method ('getRepository ' )
375+ ->with (\stdClass::class)
376+ ->willReturn ($ repository );
377+
378+ $ language ->expects ($ this ->once ())
379+ ->method ('evaluate ' )
380+ ->with ($ expr , [
381+ 'repository ' => $ repository ,
382+ 'request ' => $ request ,
383+ 'id ' => 5 ,
384+ ])
385+ ->willReturn ($ objects = [new \stdClass (), new \stdClass ()]);
386+
387+ $ this ->assertSame ([$ objects ], $ resolver ->resolve ($ request , $ argument ));
388+ }
389+
346390 public function testExpressionSyntaxErrorThrowsException ()
347391 {
348392 $ manager = $ this ->getMockBuilder (ObjectManager::class)->getMock ();
@@ -364,6 +408,7 @@ public function testExpressionSyntaxErrorThrowsException()
364408
365409 $ manager ->expects ($ this ->once ())
366410 ->method ('getRepository ' )
411+ ->with (\stdClass::class)
367412 ->willReturn ($ repository );
368413
369414 $ language ->expects ($ this ->once ())
0 commit comments