File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ public function getContext()
144144 */
145145 public function generate ($ name , $ parameters = array (), $ absolute = false )
146146 {
147- if (isset ($ parameters ['route ' ])) {
147+ if (isset ($ parameters ['route ' ]) && $ parameters [ ' route ' ] !== '' ) {
148148 $ route = $ parameters ['route ' ];
149149 } else {
150150 $ route = $ this ->getRouteFromContent ($ parameters );
Original file line number Diff line number Diff line change @@ -102,6 +102,34 @@ public function testGenerateHome()
102102 $ this ->assertEquals ('/base/ ' , $ url );
103103 }
104104
105+ public function testGenerateEmptyRouteString ()
106+ {
107+ $ this ->container ->expects ($ this ->once ())
108+ ->method ('get ' )
109+ ->with ('request ' )
110+ ->will ($ this ->returnValue ($ this ->request )
111+ );
112+
113+ $ this ->container ->expects ($ this ->any ())
114+ ->method ('get ' )
115+ ->with ('request ' )
116+ ->will ($ this ->returnValue ($ this ->request )
117+ );
118+
119+ $ this ->contentDocument ->expects ($ this ->once ())
120+ ->method ('getRoutes ' )
121+ ->will ($ this ->returnValue (array (new RouteMock ('/idprefix ' ))));
122+
123+ $ context = $ this ->buildMock ('Symfony \\Component \\Routing \\RequestContext ' );
124+ $ context ->expects ($ this ->once ())
125+ ->method ('getBaseUrl ' )
126+ ->will ($ this ->returnValue ('/base ' ));
127+ $ this ->router ->setContext ($ context );
128+
129+ $ url = $ this ->router ->generate ('ignore ' , array ('content ' =>$ this ->contentDocument , 'route ' => '' ));
130+ $ this ->assertEquals ('/base/ ' , $ url );
131+ }
132+
105133 public function testGenerateAbsolute ()
106134 {
107135 $ this ->container ->expects ($ this ->once ())
You can’t perform that action at this time.
0 commit comments