18
18
use Symfony \Component \HttpFoundation \RequestStack ;
19
19
use Symfony \Component \HttpFoundation \Response ;
20
20
use Symfony \Component \HttpFoundation \Session \Flash \FlashBag ;
21
+ use Symfony \Component \HttpFoundation \StreamedResponse ;
22
+ use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
21
23
use Symfony \Component \Security \Core \Authentication \Token \AnonymousToken ;
22
24
use Symfony \Component \Security \Core \Authentication \Token \UsernamePasswordToken ;
23
25
use Symfony \Component \Security \Core \User \User ;
@@ -270,15 +272,15 @@ public function testGenerateUrl()
270
272
$ container = $ this ->getMock ('Symfony\Component\DependencyInjection\ContainerInterface ' );
271
273
$ container ->expects ($ this ->at (0 ))->method ('get ' )->will ($ this ->returnValue ($ router ));
272
274
273
- $ controller = new Controller ();
275
+ $ controller = new TestController ();
274
276
$ controller ->setContainer ($ container );
275
277
276
278
$ this ->assertEquals ('/foo ' , $ controller ->generateUrl ('foo ' ));
277
279
}
278
280
279
281
public function testRedirect ()
280
282
{
281
- $ controller = new Controller ();
283
+ $ controller = new TestController ();
282
284
$ response = $ controller ->redirect ('http://dunglas.fr ' , 301 );
283
285
284
286
$ this ->assertInstanceOf ('Symfony\Component\HttpFoundation\RedirectResponse ' , $ response );
@@ -295,7 +297,7 @@ public function testRenderViewTemplating()
295
297
$ container ->expects ($ this ->at (0 ))->method ('has ' )->willReturn (true );
296
298
$ container ->expects ($ this ->at (1 ))->method ('get ' )->will ($ this ->returnValue ($ templating ));
297
299
298
- $ controller = new Controller ();
300
+ $ controller = new TestController ();
299
301
$ controller ->setContainer ($ container );
300
302
301
303
$ this ->assertEquals ('bar ' , $ controller ->renderView ('foo ' ));
@@ -310,7 +312,7 @@ public function testRenderTemplating()
310
312
$ container ->expects ($ this ->at (0 ))->method ('has ' )->willReturn (true );
311
313
$ container ->expects ($ this ->at (1 ))->method ('get ' )->will ($ this ->returnValue ($ templating ));
312
314
313
- $ controller = new Controller ();
315
+ $ controller = new TestController ();
314
316
$ controller ->setContainer ($ container );
315
317
316
318
$ this ->assertEquals ('bar ' , $ controller ->render ('foo ' )->getContent ());
@@ -324,15 +326,15 @@ public function testStreamTemplating()
324
326
$ container ->expects ($ this ->at (0 ))->method ('has ' )->willReturn (true );
325
327
$ container ->expects ($ this ->at (1 ))->method ('get ' )->will ($ this ->returnValue ($ templating ));
326
328
327
- $ controller = new Controller ();
329
+ $ controller = new TestController ();
328
330
$ controller ->setContainer ($ container );
329
331
330
332
$ this ->assertInstanceOf ('Symfony\Component\HttpFoundation\StreamedResponse ' , $ controller ->stream ('foo ' ));
331
333
}
332
334
333
335
public function testCreateNotFoundException ()
334
336
{
335
- $ controller = new Controller ();
337
+ $ controller = new TestController ();
336
338
337
339
$ this ->assertInstanceOf ('Symfony\Component\HttpKernel\Exception\NotFoundHttpException ' , $ controller ->createNotFoundException ());
338
340
}
@@ -347,7 +349,7 @@ public function testCreateForm()
347
349
$ container = $ this ->getMock ('Symfony\Component\DependencyInjection\ContainerInterface ' );
348
350
$ container ->expects ($ this ->at (0 ))->method ('get ' )->will ($ this ->returnValue ($ formFactory ));
349
351
350
- $ controller = new Controller ();
352
+ $ controller = new Tes
8000
tController ();
351
353
$ controller ->setContainer ($ container );
352
354
353
355
$ this ->assertEquals ($ form , $ controller ->createForm ('foo ' ));
@@ -363,7 +365,7 @@ public function testCreateFormBuilder()
363
365
$ container = $ this ->getMock ('Symfony\Component\DependencyInjection\ContainerInterface ' );
364
366
$ container ->expects ($ this ->at (0 ))->method ('get ' )->will ($ this ->returnValue ($ formFactory ));
365
367
366
- $ controller = new Controller ();
368
+ $ controller = new TestController ();
367
369
$ controller ->setContainer ($ container );
368
370
369
371
$ this ->assertEquals ($ formBuilder , $ controller ->createFormBuilder ('foo ' ));
@@ -377,7 +379,7 @@ public function testGetDoctrine()
377
379
$ container ->expects ($ this ->at (0 ))->method ('has ' )->will ($ this ->returnValue (true ));
378
380
$ container ->expects ($ this ->at (1 ))->method ('get ' )->will ($ this ->returnValue ($ doctrine ));
379
381
380
- $ controller = new Controller ();
382
+ $ controller = new TestController ();
381
383
$ controller ->setContainer ($ container );
382
384
383
385
$ this ->assertEquals ($ doctrine , $ controller ->getDoctrine ());
@@ -386,6 +388,16 @@ public function testGetDoctrine()
386
388
387
389
class TestController extends Controller
388
390
{
391
+ public function generateUrl ($ route , $ parameters = array (), $ referenceType = UrlGeneratorInterface::ABSOLUTE_PATH )
392
+ {
393
+ return parent ::generateUrl ($ route , $ parameters , $ referenceType );
394
+ }
395
+
396
+ public function redirect ($ url , $ status = 302 )
397
+ {
398
+ return parent ::redirect ($ url , $ status );
399
+ }
400
+
389
401
public function forward ($ controller , array $ path = array (), array $ query = array ())
390
402
{
391
403
return parent ::forward ($ controller , $ path , $ query );
@@ -420,4 +432,44 @@ public function isCsrfTokenValid($id, $token)
420
432
{
421
433
return parent ::isCsrfTokenValid ($ id , $ token );
422
434
}
435
+
436
+ public function renderView ($ view , array $ parameters = array ())
437
+ {
438
+ return parent ::renderView ($ view , $ parameters );
439
+ }
440
+
441
+ public function render ($ view , array $ parameters = array (), Response $ response = null )
442
+ {
443
+ return parent ::render ($ view , $ parameters , $ response );
444
+ }
445
+
446
+ public function stream ($ view , array $ parameters = array (), StreamedResponse $ response = null )
447
+ {
448
+ return parent ::stream ($ view , $ parameters , $ response );
449
+ }
450
+
451
+ public function createNotFoundException ($ message = 'Not Found ' , \Exception $ previous = null )
452
+ {
453
+ return parent ::createNotFoundException ($ message , $ previous );
454
+ }
455
+
456
+ public function createAccessDeniedException ($ message = 'Access Denied. ' , \Exception $ previous = null )
457
+ {
458
+ return parent ::createAccessDeniedException ($ message , $ previous );
459
+ }
8EAC
460
+
461
+ public function createForm ($ type , $ data = null , array $ options = array ())
462
+ {
463
+ return parent ::createForm ($ type , $ data , $ options );
464
+ }
465
+
466
+ public function createFormBuilder ($ data = null , array $ options = array ())
467
+ {
468
+ return parent ::createFormBuilder ($ data , $ options );
469
+ }
470
+
471
+ public function getDoctrine ()
472
+ {
473
+ return parent ::getDoctrine ();
474
+ }
423
475
}
0 commit comments