66
77use PHPUnit \Framework \MockObject \MockObject ;
88use PHPUnit \Framework \TestCase ;
9+ use Symfony \Component \Routing \Loader \Configurator \Traits \LocalizedRouteTrait ;
910use Symfony \Component \Routing \Route ;
1011use Symfony \Component \Routing \RouteCollection ;
1112use Symfony \Component \Routing \RouterInterface ;
1516
1617final class AnalyserTest extends TestCase
1718{
19+ use LocalizedRouteTrait;
20+
1821 public function testAnalysis (): void
1922 {
2023 $ routeCollection = new RouteCollection ();
@@ -24,26 +27,32 @@ public function testAnalysis(): void
2427 $ routeCollection ->add ('ignored_route1 ' , new Route ('/ignored_route1 ' ));
2528 $ routeCollection ->add ('_wdt ' , new Route ('/_wdt ' ));
2629 $ routeCollection ->add ('_wdt_stylesheet ' , new Route ('/_wdt_stylesheet ' ));
30+ $ this ->createLocalizedRoute ($ routeCollection , 'localized_route_simple_path ' , '/localized ' );
31+ $ this ->createLocalizedRoute ($ routeCollection , 'localized_route_multiple_paths ' , [
32+ 'en ' => '/en/localized ' ,
33+ 'fr ' => '/fr/localized ' ,
34+ 'de ' => '/de/localized ' ,
35+ ]);
2736
2837 /** @var RouterInterface&MockObject $router */
2938 $ router = $ this ->createMock (RouterInterface::class);
3039 $ router ->expects ($ this ->once ())
3140 ->method ('getRouteCollection ' )
3241 ->willReturn ($ routeCollection );
3342
34- /** @®ar RouteStorageInterface&MockObject $routeStorage */
43+ /** @var RouteStorageInterface&MockObject $routeStorage */
3544 $ routeStorage = $ this ->createMock (RouteStorageInterface::class);
3645 $ routeStorage ->expects ($ this ->exactly (2 ))
3746 ->method ('getRoutes ' )
3847 ->willReturn (['route1 ' => [200 ], 'route2 ' => [404 ]]);
3948
4049 $ analyser = new Analyser ($ router , $ routeStorage );
4150
42- $ result = $ analyser ->run (['ignored_.* ' ]);
51+ $ result = $ analyser ->run (routesToIgnore: ['ignored_.* ' ]);
4352
4453 $ this ->assertInstanceOf (AnalysisResult::class, $ result );
4554 $ this ->assertSame (['route1 ' , 'route2 ' ], $ result ->getTestedRoutes ());
46- $ this ->assertSame (['route3 ' ], $ result ->getNotTestedRoutes ());
55+ $ this ->assertSame (['route3 ' , ' localized_route_simple_path ' , ' localized_route_multiple_paths ' ], $ result ->getNotTestedRoutes ());
4756 $ this ->assertSame (['route1 ' ], $ result ->getSuccessfullyTestedRoutes ());
4857 $ this ->assertSame (['route2 ' ], $ result ->getNotSuccessfullyTestedRoutes ());
4958 }
0 commit comments