Skip to content

Commit 95effeb

Browse files
Merge branch '6.0' into 6.1
* 6.0: [HttpKernel] Fix empty request stack when terminating with exception [HttpKernel] Remove EOL when using error_log() in HttpKernel Logger [HttpClient] Add test case for seeking into the content of RetryableHttpClient responses [HttpClient] Fix buffering after calling AsyncContext::passthru() s/annd/and s/gargage/garbage [Console] Fix error output on windows cli Reserve keys when using numeric ones add missing Azerbaijani translations fix few typos/inconsistencies in latvian translations Fix TypeError in Router when using UrlGenerator [Messenger] Fix amqp socket lost fix: use message object from event
2 parents f8c1ebb + 3b7384f commit 95effeb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Router.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,12 @@ public function getGenerator(): UrlGeneratorInterface
299299

300300
if (null === $this->options['cache_dir']) {
301301
$routes = $this->getRouteCollection();
302-
$aliases = [];
303302
$compiled = is_a($this->options['generator_class'], CompiledUrlGenerator::class, true);
304303
if ($compiled) {
305304
$generatorDumper = new CompiledUrlGeneratorDumper($routes);
306-
$routes = $generatorDumper->getCompiledRoutes();
307-
$aliases = $generatorDumper->getCompiledAliases();
305+
$routes = array_merge($generatorDumper->getCompiledRoutes(), $generatorDumper->getCompiledAliases());
308306
}
309-
$this->generator = new $this->options['generator_class'](array_merge($routes, $aliases), $this->context, $this->logger, $this->defaultLocale);
307+
$this->generator = new $this->options['generator_class']($routes, $this->context, $this->logger, $this->defaultLocale);
310308
} else {
311309
$cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/url_generating_routes.php',
312310
function (ConfigCacheInterface $cache) {

Tests/RouterTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Loader\LoaderInterface;
1616
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\Routing\Generator\CompiledUrlGenerator;
1718
use Symfony\Component\Routing\Generator\UrlGenerator;
1819
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1920
use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
@@ -124,11 +125,24 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured()
124125
{
125126
$this->router->setOption('cache_dir', null);
126127

128+
$this->loader->expects($this->once())
129+
->method('load')->with('routing.yml', null)
130+
->willReturn(new RouteCollection());
131+
132+
$this->assertInstanceOf(CompiledUrlGenerator::class, $this->router->getGenerator());
133+
}
134+
135+
public function testGeneratorIsCreatedIfCacheIsNotConfiguredNotCompiled()
136+
{
137+
$this->router->setOption('cache_dir', null);
138+
$this->router->setOption('generator_class', UrlGenerator::class);
139+
127140
$this->loader->expects($this->once())
128141
->method('load')->with('routing.yml', null)
129142
->willReturn(new RouteCollection());
130143

131144
$this->assertInstanceOf(UrlGenerator::class, $this->router->getGenerator());
145+
$this->assertNotInstanceOf(CompiledUrlGenerator::class, $this->router->getGenerator());
132146
}
133147

134148
public function testMatchRequestWithUrlMatcherInterface()

0 commit comments

Comments
 (0)