@@ -52,6 +52,13 @@ protected function setUp(): void
52
52
$ this ->moduleConfig ->enabled = false ;
53
53
}
54
54
55
+ protected function tearDown (): void
56
+ {
57
+ parent ::tearDown ();
58
+
59
+ $ this ->resetServices ();
60
+ }
61
+
55
62
private function createRouteCollection (array $ routes = []): RouteCollection
56
63
{
57
64
$ collection = new RouteCollection (Services::locator (), $ this ->moduleConfig , new Routing ());
@@ -137,7 +144,7 @@ public function testFindGlobalsFiltersWithRedirectRoute(): void
137
144
public function testFindGlobalsAndRouteFilters (): void
138
145
{
139
146
$ collection = $ this ->createRouteCollection ();
140
- $ collection ->get ('admin ' , ' AdminController::index ' , ['filter ' => 'honeypot ' ]);
147
+ $ collection ->get ('admin ' , 'AdminController::index ' , ['filter ' => 'honeypot ' ]);
141
148
$ router = $ this ->createRouter ($ collection );
142
149
$ filters = $ this ->createFilters ();
143
150
@@ -155,7 +162,7 @@ public function testFindGlobalsAndRouteFilters(): void
155
162
public function testFindGlobalsAndRouteClassnameFilters (): void
156
163
{
157
164
$ collection = $ this ->createRouteCollection ();
158
- $ collection ->get ('admin ' , ' AdminController::index ' , ['filter ' => InvalidChars::class]);
165
+ $ collection ->get ('admin ' , 'AdminController::index ' , ['filter ' => InvalidChars::class]);
159
166
$ router = $ this ->createRouter ($ collection );
160
167
$ filters = $ this ->createFilters ();
161
168
@@ -173,7 +180,7 @@ public function testFindGlobalsAndRouteClassnameFilters(): void
173
180
public function testFindGlobalsAndRouteMultipleFilters (): void
174
181
{
175
182
$ collection = $ this ->createRouteCollection ();
176
- $ collection ->get ('admin ' , ' AdminController::index ' , ['filter ' => ['honeypot ' , InvalidChars::class]]);
183
+ $ collection ->get ('admin ' , 'AdminController::index ' , ['filter ' => ['honeypot ' , InvalidChars::class]]);
177
184
$ router = $ this ->createRouter ($ collection );
178
185
$ filters = $ this ->createFilters ();
179
186
@@ -314,4 +321,42 @@ public function testFilterOrderWithOldFilterOrder()
314
321
];
315
322
$ this ->assertSame ($ expected , $ filters );
316
323
}
324
+
325
+ public function testFindFiltersWithAnyLocales (): void
326
+ {
327
+ $ collection = $ this ->createRouteCollection ();
328
+ $ collection ->useSupportedLocalesOnly (false );
329
+ $ collection ->get ('{locale}/admin/(:segment) ' , 'AdminController::index/$1 ' );
330
+ Services::injectMock ('routes ' , $ collection );
331
+ $ router = $ this ->createRouter ($ collection );
332
+ $ filters = $ this ->createFilters ();
333
+ $ finder = new FilterFinder ($ router , $ filters );
334
+
335
+ $ filters = $ finder ->find ('{locale}/admin/settings ' );
336
+
337
+ $ expected = [
338
+ 'before ' => ['csrf ' ],
339
+ 'after ' => ['toolbar ' ],
340
+ ];
341
+ $ this ->assertSame ($ expected , $ filters );
342
+ }
343
+
344
+ public function testFindFiltersWithSupportedLocalesOnly (): void
345
+ {
346
+ $ collection = $ this ->createRouteCollection ();
347
+ $ collection ->useSupportedLocalesOnly (true );
348
+ $ collection ->get ('{locale}/admin/(:segment) ' , 'AdminController::index/$1 ' );
349
+ Services::injectMock ('routes ' , $ collection );
350
+ $ router = $ this ->createRouter ($ collection );
351
+ $ filters = $ this ->createFilters ();
352
+ $ finder = new FilterFinder ($ router , $ filters );
353
+
354
+ $ filters = $ finder ->find ('{locale}/admin/settings ' );
355
+
356
+ $ expected = [
357
+ 'before ' => ['!csrf ' ],
358
+ 'after ' => ['!toolbar ' ],
359
+ ];
360
+ $ this ->assertSame ($ expected , $ filters );
361
+ }
317
362
}
0 commit comments