|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase; |
15 | 15 | use Symfony\Component\Config\FileLocator; |
| 16 | +use Symfony\Component\HttpKernel\Config\FileLocator as KernelFileLocator; |
| 17 | +use Symfony\Component\HttpKernel\KernelInterface; |
16 | 18 | use Symfony\Component\Routing\Loader\PhpFileLoader; |
17 | 19 | use Symfony\Component\Routing\Loader\XmlFileLoader; |
18 | 20 | use Symfony\Component\Routing\RouteCollection; |
19 | 21 |
|
20 | 22 | class RoutingTest extends TestCase |
21 | 23 | { |
| 24 | + private const BUNDLE_PREFIX = '@FOSUserBundle/'; |
| 25 | + private const SOURCE_DIR = __DIR__.'/../../src'; |
| 26 | + |
| 27 | + public function testLoadAllRouting(): void |
| 28 | + { |
| 29 | + $kernel = $this->createMock(KernelInterface::class); |
| 30 | + $kernel->method('locateResource')->willReturnCallback(static function (string $resource): string { |
| 31 | + self::assertStringStartsWith(self::BUNDLE_PREFIX, $resource); |
| 32 | + |
| 33 | + return self::SOURCE_DIR.'/'.substr($resource, \strlen(self::BUNDLE_PREFIX)); |
| 34 | + }); |
| 35 | + |
| 36 | + $loader = new PhpFileLoader(new KernelFileLocator($kernel)); |
| 37 | + $collection = $loader->load(self::SOURCE_DIR.'/Resources/config/routing/all.php'); |
| 38 | + |
| 39 | + $expectedRouteNames = array_column(self::loadRoutingProvider(), 0); |
| 40 | + $actualRouteNames = array_keys($collection->all()); |
| 41 | + sort($expectedRouteNames); |
| 42 | + sort($actualRouteNames); |
| 43 | + |
| 44 | + self::assertSame($expectedRouteNames, $actualRouteNames); |
| 45 | + } |
| 46 | + |
22 | 47 | /** |
23 | 48 | * @dataProvider loadRoutingProvider |
24 | 49 | * |
|
0 commit comments