@@ -428,6 +428,68 @@ public function testGenerateNotFound()
428
428
$ this ->assertEquals ($ url , $ result );
429
429
}
430
430
431
+ public function testGenerateObjectName ()
432
+ {
433
+ $ name = new \stdClass ();
434
+ $ parameters = array ('test ' => 'value ' );
435
+
436
+ $ defaultRouter = $ this ->getMock ('Symfony \\Component \\Routing \\RouterInterface ' );
437
+ $ chainedRouter = $ this ->getMock ('Symfony \\Cmf \\Component \\Routing \\ChainedRouterInterface ' );
438
+
439
+ $ defaultRouter
440
+ ->expects ($ this ->never ())
441
+ ->method ('generate ' )
442
+ ;
443
+ $ chainedRouter
444
+ ->expects ($ this ->once ())
445
+ ->method ('supports ' )
446
+ ->will ($ this ->returnValue (true ))
447
+ ;
448
+ $ chainedRouter
449
+ ->expects ($ this ->once ())
450
+ ->method ('generate ' )
451
+ ->with ($ name , $ parameters , false )
452
+ ->will ($ this ->returnValue ($ name ))
453
+ ;
454
+
455
+ $ this ->router ->add ($ defaultRouter , 200 );
456
+ $ this ->router ->add ($ chainedRouter , 100 );
457
+
458
+ $ result = $ this ->router ->generate ($ name , $ parameters );
459
+ $ this ->assertEquals ($ name , $ result );
460
+ }
461
+
462
+ public function testGenerateNonDefaultStringName ()
463
+ {
464
+ $ name = '/test/this ' ;
465
+ $ parameters = array ('test ' => 'value ' );
466
+
467
+ $ defaultRouter = $ this ->getMock ('Symfony \\Component \\Routing \\RouterInterface ' );
468
+ $ chainedRouter = $ this ->getMock ('Symfony \\Cmf \\Component \\Routing \\ChainedRouterInterface ' );
469
+
470
+ $ defaultRouter
471
+ ->expects ($ this ->never ())
472
+ ->method ('generate ' )
473
+ ;
474
+ $ chainedRouter
475
+ ->expects ($ this ->once ())
476
+ ->method ('supports ' )
477
+ ->will ($ this ->returnValue (true ))
478
+ ;
479
+ $ chainedRouter
480
+ ->expects ($ this ->once ())
481
+ ->method ('generate ' )
482
+ ->with ($ name , $ parameters , false )
483
+ ->will ($ this ->returnValue ($ name ))
484
+ ;
485
+
486
+ $ this ->router ->add ($ defaultRouter , 200 );
487
+ $ this ->router ->add ($ chainedRouter , 100 );
488
+
489
+ $ result = $ this ->router ->generate ($ name , $ parameters );
490
+ $ this ->assertEquals ($ name , $ result );
491
+ }
492
+
431
493
public function testWarmup ()
432
494
{
433
495
$ dir = 'test_dir ' ;
0 commit comments