Skip to content

Commit 4e872f7

Browse files
committed
test: Move code to RoutesTest.php
1 parent 231a748 commit 4e872f7

File tree

2 files changed

+28
-45
lines changed

2 files changed

+28
-45
lines changed

tests/system/Commands/RoutesTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,32 @@ public function testRoutesCommandRouteLegacy(): void
223223
EOL;
224224
$this->assertStringContainsString($expected, $this->getBuffer());
225225
}
226+
227+
public function testRoutesCommandWithAnyLocales(): void
228+
{
229+
$routes = $this->getCleanRoutes();
230+
$routes->useSupportedLocalesOnly(false);
231+
$routes->get('{locale}/admin/(:segment)', 'AdminController::index/$1', ['as' => 'admin']);
232+
233+
command('routes');
234+
235+
$expected = <<<'EOL'
236+
| GET | {locale}/admin/([^/]+) | admin | \App\Controllers\AdminController::index/$1 | | toolbar |
237+
EOL;
238+
$this->assertStringContainsString($expected, $this->getBuffer());
239+
}
240+
241+
public function testRoutesCommandWithSupportedLocalesOnly(): void
242+
{
243+
$routes = $this->getCleanRoutes();
244+
$routes->useSupportedLocalesOnly(true);
245+
$routes->get('{locale}/admin/(:segment)', 'AdminController::index/$1', ['as' => 'admin']);
246+
247+
command('routes');
248+
249+
$expected = <<<'EOL'
250+
| GET | {locale}/admin/([^/]+) | admin | \App\Controllers\AdminController::index/$1 | | !toolbar |
251+
EOL;
252+
$this->assertStringContainsString($expected, $this->getBuffer());
253+
}
226254
}

tests/system/Commands/Utilities/Routes/FilterFinderTest.php

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ protected function setUp(): void
5252
$this->moduleConfig->enabled = false;
5353
}
5454

55-
protected function tearDown(): void
56-
{
57-
parent::tearDown();
58-
59-
$this->resetServices();
60-
}
61-
6255
private function createRouteCollection(array $routes = []): RouteCollection
6356
{
6457
$collection = new RouteCollection(Services::locator(), $this->moduleConfig, new Routing());
@@ -321,42 +314,4 @@ public function testFilterOrderWithOldFilterOrder()
321314
];
322315
$this->assertSame($expected, $filters);
323316
}
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-
}
362317
}

0 commit comments

Comments
 (0)