|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\Routing\Tests\Loader;
|
13 | 13 |
|
| 14 | +use Doctrine\Common\Annotations\AnnotationReader; |
14 | 15 | use PHPUnit\Framework\TestCase;
|
15 | 16 | use Symfony\Component\Config\FileLocator;
|
| 17 | +use Symfony\Component\Config\Loader\LoaderResolver; |
16 | 18 | use Symfony\Component\Config\Resource\FileResource;
|
| 19 | +use Symfony\Component\Routing\Loader\AnnotationClassLoader; |
17 | 20 | use Symfony\Component\Routing\Loader\YamlFileLoader;
|
18 | 21 | use Symfony\Component\Routing\Route;
|
19 | 22 | use Symfony\Component\Routing\RouteCollection;
|
@@ -458,4 +461,27 @@ public function testImportingAliases()
|
458 | 461 |
|
459 | 462 | $this->assertEquals($expectedRoutes('yaml'), $routes);
|
460 | 463 | }
|
| 464 | + |
| 465 | + public function testPriorityWithPrefix() |
| 466 | + { |
| 467 | + new LoaderResolver([ |
| 468 | + $loader = new YamlFileLoader(new FileLocator(\dirname(__DIR__).'/Fixtures/localized')), |
| 469 | + new class(new AnnotationReader(), null) extends AnnotationClassLoader { |
| 470 | + protected function configureRoute( |
| 471 | + Route $route, |
| 472 | + \ReflectionClass $class, |
| 473 | + \ReflectionMethod $method, |
| 474 | + object $annot |
| 475 | + ): void { |
| 476 | + $route->setDefault('_controller', $class->getName().'::'.$method->getName()); |
| 477 | + } |
| 478 | + }, |
| 479 | + ]); |
| 480 | + |
| 481 | + $routes = $loader->load('localized-prefix.yml'); |
| 482 | + |
| 483 | + $this->assertEquals(2, $routes->getPriority('important.cs')); |
| 484 | + $this->assertEquals(2, $routes->getPriority('important.en')); |
| 485 | + $this->assertEquals(1, $routes->getPriority('also_important')); |
| 486 | + } |
461 | 487 | }
|
0 commit comments