@@ -66,16 +66,21 @@ public function testGetRouteCollectionForRequest()
66
66
$ this ->assertCount (3 , $ routes );
67
67
$ this ->assertContainsOnlyInstancesOf (RouteObjectInterface::class, $ routes );
68
68
69
- $ routes = $ routes ->all ();
70
- list ($ key , $ child ) = each ($ routes );
71
- $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute/noroute/child ' , $ key );
72
- $ this ->assertEquals ('json ' , $ child ->getDefault ('_format ' ));
73
- list ($ key , $ testroute ) = each ($ routes );
74
- $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute ' , $ key );
75
- $ this ->assertEquals ('html ' , $ testroute ->getDefault ('_format ' ));
76
- list ($ key , $ root ) = each ($ routes );
77
- $ this ->assertEquals (self ::ROUTE_ROOT , $ key );
78
- $ this ->assertNull ($ root ->getDefault ('_format ' ));
69
+ $ iterator = $ routes ->getIterator ();
70
+
71
+ $ this ->assertTrue ($ iterator ->valid ());
72
+ $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute/noroute/child ' , $ iterator ->key ());
73
+ $ this ->assertEquals ('json ' , $ iterator ->current ()->getDefault ('_format ' ));
74
+
75
+ $ iterator ->next ();
76
+ $ this ->assertTrue ($ iterator ->valid ());
77
+ $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute ' , $ iterator ->key ());
78
+ $ this ->assertEquals ('html ' , $ iterator ->current ()->getDefault ('_format ' ));
79
+
80
+ $ iterator ->next ();
81
+ $ this ->assertTrue ($ iterator ->valid ());
82
+ $ this ->assertEquals (self ::ROUTE_ROOT , $ iterator ->key ());
83
+ $ this ->assertNull ($ iterator ->current ()->getDefault ('_format ' ));
79
84
}
80
85
81
86
public function testGetRouteCollectionForRequestFormat ()
@@ -86,29 +91,36 @@ public function testGetRouteCollectionForRequestFormat()
86
91
$ this ->assertCount (3 , $ routes );
87
92
$ this ->assertContainsOnlyInstancesOf (RouteObjectInterface::class, $ routes );
88
93
89
- $ routes = $ routes ->all ();
90
- list ($ key , $ child ) = each ($ routes );
91
- $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute/noroute/child ' , $ key );
92
- $ this ->assertEquals ('json ' , $ child ->getDefault ('_format ' ));
93
- list ($ key , $ testroute ) = each ($ routes );
94
- $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute ' , $ key );
95
- $ this ->assertEquals ('html ' , $ testroute ->getDefault ('_format ' ));
96
- list ($ key , $ root ) = each ($ routes );
97
- $ this ->assertEquals (self ::ROUTE_ROOT , $ key );
98
- $ this ->assertNull ($ root ->getDefault ('_format ' ));
94
+ $ iterator = $ routes ->getIterator ();
95
+
96
+ $ this ->assertTrue ($ iterator ->valid ());
97
+ $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute/noroute/child ' , $ iterator ->key ());
98
+ $ this ->assertEquals ('json ' , $ iterator ->current ()->getDefault ('_format ' ));
99
+
100
+ $ iterator ->next ();
101
+ $ this ->assertTrue ($ iterator ->valid ());
102
+ $ this ->assertEquals (self ::ROUTE_ROOT .'/testroute ' , $ iterator ->key ());
103
+ $ this ->assertEquals ('html ' , $ iterator ->current ()->getDefault ('_format ' ));
104
+
105
+ $ iterator ->next ();
106
+ $ this ->assertTrue ($ iterator ->valid ());
107
+ $ this ->assertEquals (self ::ROUTE_ROOT , $ iterator ->key ());
108
+ $ this ->assertNull ($ iterator ->current ()->getDefault ('_format ' ));
99
109
}
100
110
101
111
/**
102
112
* The root route will always be found.
103
113
*/
104
114
public function testGetRouteCollectionForRequestNonPhpcrUrl ()
105
115
{
106
- $ collection = $ this ->repository ->getRouteCollectionForRequest (Request::create ('http:/// ' ));
107
- $ this ->assertInstanceOf (RouteCollection::class, $ collection );
108
- $ this ->assertCount (1 , $ collection );
109
- $ routes = $ collection ->all ();
110
- list ($ key , $ route ) = each ($ routes );
111
- $ this ->assertEquals (self ::ROUTE_ROOT , $ key );
116
+ $ routes = $ this ->repository ->getRouteCollectionForRequest (Request::create ('http:/// ' ));
117
+ $ this ->assertInstanceOf (RouteCollection::class, $ routes );
118
+ $ this ->assertCount (1 , $ routes );
119
+
120
+ $ iterator = $ routes ->getIterator ();
121
+
122
+ $ this ->assertTrue ($ iterator ->valid ());
123
+ $ this ->assertEquals (self ::ROUTE_ROOT , $ iterator ->key ());
112
124
}
113
125
114
126
/**
0 commit comments