@@ -70,8 +70,8 @@ public function testIteratorWithOverriddenRoutes()
7070 $ collection ->add ('foo ' , new Route ('/foo ' ));
7171
7272 $ collection1 = new RouteCollection ();
73- $ collection ->addCollection ($ collection1 );
7473 $ collection1 ->add ('foo ' , new Route ('/foo1 ' ));
74+ $ collection ->addCollection ($ collection1 );
7575
7676 $ this ->assertEquals ('/foo1 ' , $ this ->getFirstNamedRoute ($ collection , 'foo ' )->getPattern ());
7777 }
@@ -82,8 +82,8 @@ public function testCount()
8282 $ collection ->add ('foo ' , new Route ('/foo ' ));
8383
8484 $ collection1 = new RouteCollection ();
85- $ collection ->addCollection ($ collection1 );
8685 $ collection1 ->add ('foo1 ' , new Route ('/foo1 ' ));
86+ $ collection ->addCollection ($ collection1 );
8787
8888 $ this ->assertCount (2 , $ collection );
8989 }
@@ -212,19 +212,12 @@ public function testUniqueRouteWithGivenName()
212212 $ collection3 = new RouteCollection ();
213213 $ collection3 ->add ('foo ' , $ new = new Route ('/new ' ));
214214
215- $ collection1 ->addCollection ($ collection2 );
216215 $ collection2 ->addCollection ($ collection3 );
217-
218- $ collection1 ->add ('stay ' , new Route ('/stay ' ));
219-
220- $ iterator = $ collection1 ->getIterator ();
216+ $ collection1 ->addCollection ($ collection2 );
221217
222218 $ this ->assertSame ($ new , $ collection1 ->get ('foo ' ), '->get() returns new route that overrode previous one ' );
223- // size of 2 because collection1 contains collection2 and /stay but not /old anymore
224- $ this ->assertCount (2 , $ iterator , '->addCollection() removes previous routes when adding new routes with the same name ' );
225- $ this ->assertInstanceOf ('Symfony\Component\Routing\RouteCollection ' , $ iterator ->current (), '->getIterator returns both Routes and RouteCollections ' );
226- $ iterator ->next ();
227- $ this ->assertInstanceOf ('Symfony\Component\Routing\Route ' , $ iterator ->current (), '->getIterator returns both Routes and RouteCollections ' );
219+ // size of 1 because collection1 contains /new but not /old anymore
220+ $ this ->assertCount (1 , $ collection1 ->getIterator (), '->addCollection() removes previous routes when adding new routes with the same name ' );
228221 }
229222
230223 public function testGet ()
@@ -241,63 +234,6 @@ public function testGet()
241234 $ this ->assertNull ($ collection1 ->get (0 ), '->get() does not disclose internal child RouteCollection ' );
242235 }
243236
244- /**
245- * @expectedException \InvalidArgumentException
246- */
247- public function testCannotSelfJoinCollection ()
248- {
249- $ collection = new RouteCollection ();
250-
251- $ collection ->addCollection ($ collection );
252- }
253-
254- /**
255- * @expectedException \InvalidArgumentException
256- */
257- public function testCannotAddExistingCollectionToTree ()
258- {
259- $ collection1 = new RouteCollection ();
260- $ collection2 = new RouteCollection ();
261- $ collection3 = new RouteCollection ();
262-
263- $ collection1 ->addCollection ($ collection2 );
264- $ collection1 ->addCollection ($ collection3 );
265- $ collection2 ->addCollection ($ collection3 );
266- }
267-
268- public function testPatternDoesNotChangeWhenDefinitionOrderChanges ()
269- {
270- $ collection1 = new RouteCollection ();
271- $ collection1 ->add ('a ' , new Route ('/a... ' ));
272- $ collection2 = new RouteCollection ();
273- $ collection2 ->add ('b ' , new Route ('/b... ' ));
274- $ collection3 = new RouteCollection ();
275- $ collection3 ->add ('c ' , new Route ('/c... ' ));
276-
277- $ rootCollection_A = new RouteCollection ();
278- $ collection2 ->addCollection ($ collection3 , '/c ' );
279- $ collection1 ->addCollection ($ collection2 , '/b ' );
280- $ rootCollection_A ->addCollection ($ collection1 , '/a ' );
281-
282- // above should mean the same as below
283-
284- $ collection1 = new RouteCollection ();
285- $ collection1 ->add ('a ' , new Route ('/a... ' ));
286- $ collection2 = new RouteCollection ();
287- $ collection2 ->add ('b ' , new Route ('/b... ' ));
288- $ collection3 = new RouteCollection ();
289- $ collection3 ->add ('c ' , new Route ('/c... ' ));
290-
291- $ rootCollection_B = new RouteCollection ();
292- $ collection1 ->addCollection ($ collection2 , '/b ' );
293- $ collection2 ->addCollection ($ collection3 , '/c ' );
294- $ rootCollection_B ->addCollection ($ collection1 , '/a ' );
295-
296- // test it now
297-
298- $ this ->assertEquals ($ rootCollection_A , $ rootCollection_B );
299- }
300-
301237 public function testSetHostnamePattern ()
302238 {
303239 $ collection = new RouteCollection ();
0 commit comments