@@ -298,6 +298,7 @@ public function testExpressionFailureReturns404()
298
298
299
299
$ manager ->expects ($ this ->once ())
300
300
->method ('getRepository ' )
301
+ ->with (\stdClass::class)
301
302
->willReturn ($ repository );
302
303
303
304
$ language ->expects ($ this ->once ())
@@ -329,6 +330,7 @@ public function testExpressionMapsToArgument()
329
330
330
331
$ manager ->expects ($ this ->once ())
331
332
->method ('getRepository ' )
333
+ ->with (\stdClass::class)
332
334
->willReturn ($ repository );
333
335
334
336
$ language ->expects ($ this ->once ())
@@ -343,6 +345,48 @@ public function testExpressionMapsToArgument()
343
345
$ this ->assertSame ([$ object ], $ resolver ->resolve ($ request , $ argument ));
344
346
}
345
347
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
+
346
390
public function testExpressionSyntaxErrorThrowsException ()
347
391
{
348
392
$ manager = $ this ->getMockBuilder (ObjectManager::class)->getMock ();
@@ -364,6 +408,7 @@ public function testExpressionSyntaxErrorThrowsException()
364
408
365
409
$ manager ->expects ($ this ->once ())
366
410
->method ('getRepository ' )
411
+ ->with (\stdClass::class)
367
412
->willReturn ($ repository );
368
413
369
414
$ language ->expects ($ this ->once ())
0 commit comments