@@ -103,6 +103,31 @@ public function testLoadingRouteWithDefaults()
103
103
$ this ->assertSame ('html ' , $ defaultsRoute ->getDefault ('_format ' ));
104
104
}
105
105
106
+ public function testLoadingRouteWithCollectionDefaults ()
107
+ {
108
+ $ loader = new PhpFileLoader (new FileLocator ([__DIR__ .'/../Fixtures ' ]));
109
+ $ routes = $ loader ->load ('collection-defaults.php ' );
110
+
111
+ $ this ->assertCount (2 , $ routes );
112
+
113
+ $ defaultsRoute = $ routes ->get ('defaultsA ' );
114
+ $ this ->assertSame (['GET ' ], $ defaultsRoute ->getMethods ());
115
+ $ this ->assertArrayHasKey ('attribute ' , $ defaultsRoute ->getDefaults ());
116
+ $ this ->assertTrue ($ defaultsRoute ->getDefault ('_stateless ' ));
117
+ $ this ->assertSame ('/defaultsA ' , $ defaultsRoute ->getPath ());
118
+ $ this ->assertSame ('en ' , $ defaultsRoute ->getDefault ('_locale ' ));
119
+ $ this ->assertSame ('html ' , $ defaultsRoute ->getDefault ('_format ' ));
120
+
121
+ // The second route has a specific method and is not stateless, overwriting the collection settings
122
+ $ defaultsRoute = $ routes ->get ('defaultsB ' );
123
+ $ this ->assertSame (['POST ' ], $ defaultsRoute ->getMethods ());
124
+ $ this ->assertArrayHasKey ('attribute ' , $ defaultsRoute ->getDefaults ());
125
+ $ this ->assertFalse ($ defaultsRoute ->getDefault ('_stateless ' ));
126
+ $ this ->assertSame ('/defaultsB ' , $ defaultsRoute ->getPath ());
127
+ $ this ->assertSame ('en ' , $ defaultsRoute ->getDefault ('_locale ' ));
128
+ $ this ->assertSame ('html ' , $ defaultsRoute ->getDefault ('_format ' ));
129
+ }
130
+
106
131
public function testLoadingImportedRoutesWithDefaults ()
107
132
{
108
133
$ loader = new PhpFileLoader (new FileLocator ([__DIR__ .'/../Fixtures ' ]));
0 commit comments