|
13 | 13 |
|
14 | 14 | use Symfony\Component\Routing\Matcher\CompiledUrlMatcher; |
15 | 15 | use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper; |
| 16 | +use Symfony\Component\Routing\Matcher\UrlMatcher; |
16 | 17 | use Symfony\Component\Routing\RequestContext; |
| 18 | +use Symfony\Component\Routing\Route; |
17 | 19 | use Symfony\Component\Routing\RouteCollection; |
18 | 20 |
|
19 | 21 | class CompiledUrlMatcherTest extends UrlMatcherTest |
20 | 22 | { |
| 23 | + public function testStaticHostIsCaseInsensitive() |
| 24 | + { |
| 25 | + $collection = new RouteCollection(); |
| 26 | + $collection->add('static_host_route', new Route('/test', [], [], [], 'API.example.com')); |
| 27 | + |
| 28 | + $context = new RequestContext('/test', 'GET', 'api.example.com'); |
| 29 | + $matcher = new UrlMatcher($collection, $context); |
| 30 | + |
| 31 | + $result = $matcher->match('/test'); |
| 32 | + $this->assertEquals('static_host_route', $result['_route'], 'UrlMatcher should match case-insensitive host'); |
| 33 | + |
| 34 | + $dumper = new CompiledUrlMatcherDumper($collection); |
| 35 | + $compiledRoutes = $dumper->getCompiledRoutes(); |
| 36 | + |
| 37 | + $compiledMatcher = new CompiledUrlMatcher($compiledRoutes, $context); |
| 38 | + |
| 39 | + $result = $compiledMatcher->match('/test'); |
| 40 | + $this->assertEquals('static_host_route', $result['_route'], 'CompiledUrlMatcher should match case-insensitive host'); |
| 41 | + } |
| 42 | + |
21 | 43 | protected function getUrlMatcher(RouteCollection $routes, ?RequestContext $context = null) |
22 | 44 | { |
23 | 45 | $dumper = new CompiledUrlMatcherDumper($routes); |
|
0 commit comments