@@ -66,16 +66,21 @@ public function testGetRouteCollectionForRequest()
6666 $ this ->assertCount (3 , $ routes );
6767 $ this ->assertContainsOnlyInstancesOf (RouteObjectInterface::class, $ routes );
6868
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 ' ));
7984 }
8085
8186 public function testGetRouteCollectionForRequestFormat ()
@@ -86,29 +91,36 @@ public function testGetRouteCollectionForRequestFormat()
8691 $ this ->assertCount (3 , $ routes );
8792 $ this ->assertContainsOnlyInstancesOf (RouteObjectInterface::class, $ routes );
8893
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 ' ));
99109 }
100110
101111 /**
102112 * The root route will always be found.
103113 */
104114 public function testGetRouteCollectionForRequestNonPhpcrUrl ()
105115 {
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 ());
112124 }
113125
114126 /**
0 commit comments