@@ -54,16 +54,19 @@ public function testDeepOverriddenRoute()
54
54
$ this ->assertEquals ('/foo2 ' , $ collection ->get ('foo ' )->getPath ());
55
55
}
56
56
57
- public function testIteratorWithOverriddenRoutes ()
57
+ public function testIterator ()
58
58
{
59
59
$ collection = new RouteCollection ();
60
60
$ collection ->add ('foo ' , new Route ('/foo ' ));
61
61
62
62
$ collection1 = new RouteCollection ();
63
- $ collection1 ->add ('foo ' , new Route ('/foo1 ' ));
63
+ $ collection1 ->add ('bar ' , $ bar = new Route ('/bar ' ));
64
+ $ collection1 ->add ('foo ' , $ foo = new Route ('/foo-new ' ));
64
65
$ collection ->addCollection ($ collection1 );
66
+ $ collection ->add ('last ' , $ last = new Route ('/last ' ));
65
67
66
- $ this ->assertEquals ('/foo1 ' , $ this ->getFirstNamedRoute ($ collection , 'foo ' )->getPath ());
68
+ $ this ->assertInstanceOf ('\ArrayIterator ' , $ collection ->getIterator ());
69
+ $ this ->assertSame (array ('bar ' => $ bar , 'foo ' => $ foo , 'last ' => $ last ), $ collection ->getIterator ()->getArrayCopy ());
67
70
}
68
71
69
72
public function testCount ()
@@ -72,25 +75,12 @@ public function testCount()
72
75
$ collection ->add ('foo ' , new Route ('/foo ' ));
73
76
74
77
$ collection1 = new RouteCollection ();
75
- $ collection1 ->add ('foo1 ' , new Route ('/foo1 ' ));
78
+ $ collection1 ->add ('bar ' , new Route ('/bar ' ));
76
79
$ collection ->addCollection ($ collection1 );
77
80
78
81
$ this ->assertCount (2 , $ collection );
79
82
}
80
83
81
- protected function getFirstNamedRoute (RouteCollection $ routeCollection , $ name )
82
- {
83
- foreach ($ routeCollection as $ key => $ route ) {
84
- if ($ route instanceof RouteCollection) {
85
- return $ this ->getFirstNamedRoute ($ route , $ name );
86
- }
87
-
88
- if ($ name === $ key ) {
89
- return $ route ;
90
- }
91
- }
92
- }
93
-
94
84
public function testAddCollection ()
95
85
{
96
86
if (!class_exists ('Symfony\Component\Config\Resource\FileResource ' )) {
0 commit comments