@@ -29,7 +29,7 @@ class DynamicRouterTest extends CmfUnitTestCase
2929 protected $ context ;
3030 public $ request ;
3131
32- protected $ url = '/foo/bar ' ;
32+ const URL = '/foo/bar ' ;
3333
3434 public function setUp ()
3535 {
@@ -40,7 +40,7 @@ public function setUp()
4040 $ this ->enhancer = $ this ->buildMock ('Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface ' , array ('enhance ' ));
4141
4242 $ this ->context = $ this ->buildMock ('Symfony\Component\Routing\RequestContext ' );
43- $ this ->request = Request::create ($ this -> url );
43+ $ this ->request = Request::create (self :: URL );
4444
4545 $ this ->router = new DynamicRouter ($ this ->context , $ this ->matcher , $ this ->generator );
4646 $ this ->router ->addRouteEnhancer ($ this ->enhancer );
@@ -142,18 +142,21 @@ public function testMatchUrl()
142142 $ routeDefaults = array ('foo ' => 'bar ' );
143143 $ this ->matcher ->expects ($ this ->once ())
144144 ->method ('match ' )
145- ->with ($ this -> url )
145+ ->with (self :: URL )
146146 ->will ($ this ->returnValue ($ routeDefaults ))
147147 ;
148148
149149 $ expected = array ('this ' => 'that ' );
150+ $ test = $ this ;
150151 $ this ->enhancer ->expects ($ this ->once ())
151152 ->method ('enhance ' )
152- ->with ($ this ->equalTo ($ routeDefaults ), $ this ->equalTo ($ this ->request ))
153+ ->with ($ this ->equalTo ($ routeDefaults ), $ this ->callback (function (Request $ request ) use ($ test ) {
154+ return DynamicRouterTest::URL === $ request ->server ->get ('REQUEST_URI ' );
155+ }))
153156 ->will ($ this ->returnValue ($ expected ))
154157 ;
155158
156- $ results = $ this ->router ->match ($ this -> url );
159+ $ results = $ this ->router ->match (self :: URL );
157160
158161 $ this ->assertEquals ($ expected , $ results );
159162 }
@@ -164,15 +167,17 @@ public function testMatchRequestWithUrlMatcher()
164167
165168 $ this ->matcher ->expects ($ this ->once ())
166169 ->method ('match ' )
167- ->with ($ this -> url )
170+ ->with (self :: URL )
168171 ->will ($ this ->returnValue ($ routeDefaults ))
169172 ;
170173
171174 $ expected = array ('this ' => 'that ' );
175+ $ test = $ this ;
172176 $ this ->enhancer ->expects ($ this ->once ())
173177 ->method ('enhance ' )
174- // somehow request object gets confused, check on instance only
175- ->with ($ this ->equalTo ($ routeDefaults ), $ this ->isInstanceOf ('Symfony\Component\HttpFoundation\Request ' ))
178+ ->with ($ this ->equalTo ($ routeDefaults ), $ this ->callback (function (Request $ request ) use ($ test ) {
179+ return DynamicRouterTest::URL === $ request ->server ->get ('REQUEST_URI ' );
180+ }))
176181 ->will ($ this ->returnValue ($ expected ))
177182 ;
178183
@@ -195,9 +200,12 @@ public function testMatchRequest()
195200 ;
196201
197202 $ expected = array ('this ' => 'that ' );
203+ $ test = $ this ;
198204 $ this ->enhancer ->expects ($ this ->once ())
199205 ->method ('enhance ' )
200- ->with ($ this ->equalTo ($ routeDefaults ), $ this ->equalTo ($ this ->request ))
206+ ->with ($ this ->equalTo ($ routeDefaults ), $ this ->callback (function (Request $ request ) use ($ test ) {
207+ return DynamicRouterTest::URL === $ request ->server ->get ('REQUEST_URI ' );
208+ }))
201209 ->will ($ this ->returnValue ($ expected ))
202210 ;
203211
@@ -223,7 +231,7 @@ public function testMatchFilter()
223231 ->method ('enhance ' )
224232 ;
225233
226- $ router ->match ($ this -> url );
234+ $ router ->match (self :: URL );
227235 }
228236
229237 /**
@@ -256,7 +264,7 @@ public function testMatchUrlWithRequestMatcher()
256264 $ matcher = $ this ->buildMock ('Symfony\Component\Routing\Matcher\RequestMatcherInterface ' , array ('matchRequest ' , 'setContext ' , 'getContext ' ));
257265 $ router = new DynamicRouter ($ this ->context , $ matcher , $ this ->generator );
258266
259- $ router ->match ($ this -> url );
267+ $ router ->match (self :: URL );
260268 }
261269
262270 /**
@@ -301,11 +309,11 @@ public function testEventHandler()
301309 $ routeDefaults = array ('foo ' => 'bar ' );
302310 $ this ->matcher ->expects ($ this ->once ())
303311 ->method ('match ' )
304- ->with ($ this -> url )
312+ ->with (self :: URL )
305313 ->will ($ this ->returnValue ($ routeDefaults ))
306314 ;
307315
308- $ this ->assertEquals ($ routeDefaults , $ router ->match ($ this -> url ));
316+ $ this ->assertEquals ($ routeDefaults , $ router ->match (self :: URL ));
309317 }
310318
311319 public function testEventHandlerRequest ()
@@ -327,7 +335,7 @@ public function testEventHandlerRequest()
327335 $ routeDefaults = array ('foo ' => 'bar ' );
328336 $ this ->matcher ->expects ($ this ->once ())
329337 ->method ('match ' )
330- ->with ($ this -> url )
338+ ->with (self :: URL )
331339 ->will ($ this ->returnValue ($ routeDefaults ))
332340 ;
333341
0 commit comments