Skip to content

Commit 0ac14b0

Browse files
Merge branch '4.3' into 4.4
* 4.3: (26 commits) [Console] Fix #33915, Detect dimensions using mode CON if vt100 is supported [HttpKernel][DataCollectorInterface] Ease compatibility Add tests to ensure defaultLocale is properly passed to the URL generator [DependencyInjection] Fix broken references in tests [HttpClient] Retry safe requests when then fail before the body arrives Avoid using of kernel after shutdown Simplify PHP CS Fixer configuration [PropertyInfo] Fixed type extraction for nullable collections of non-nullable elements [FrameworkBundle] [HttpKernel] fixed correct EOL and EOM month [Serializer] Fix property name usage for denormalization Name test accordingly to the tested class Fix MockFileSessionStorageTest::sessionDir being used after it's unset bumped Symfony version to 4.3.7 updated VERSION for 4.3.6 updated CHANGELOG for 4.3.6 bumped Symfony version to 3.4.34 updated VERSION for 3.4.33 update CONTRIBUTORS for 3.4.33 updated CHANGELOG for 3.4.33 [HttpClient] Fix perf issue when doing thousands of requests with curl ...
2 parents 8ac2ebc + 533fd12 commit 0ac14b0

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ function (ConfigCacheInterface $cache) {
363363
);
364364

365365
if ($compiled) {
366-
$this->generator = new $this->options['generator_class'](require $cache->getPath(), $this->context, $this->logger);
366+
$this->generator = new $this->options['generator_class'](require $cache->getPath(), $this->context, $this->logger, $this->defaultLocale);
367367
} else {
368368
if (!class_exists($this->options['generator_cache_class'], false)) {
369369
require_once $cache->getPath();

Tests/RouterTest.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,26 @@ class RouterTest extends TestCase
2222

2323
private $loader = null;
2424

25+
private $cacheDir;
26+
2527
protected function setUp(): void
2628
{
2729
$this->loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
2830
$this->router = new Router($this->loader, 'routing.yml');
31+
32+
$this->cacheDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('router_', true);
33+
}
34+
35+
protected function tearDown(): void
36+
{
37+
if (is_dir($this->cacheDir)) {
38+
array_map('unlink', glob($this->cacheDir.\DIRECTORY_SEPARATOR.'*'));
39+
rmdir($this->cacheDir);
40+
}
41+
42+
$this->loader = null;
43+
$this->router = null;
44+
$this->cacheDir = null;
2945
}
3046

3147
public function testSetOptionsWithSupportedOptions()
@@ -132,4 +148,68 @@ public function testMatchRequestWithRequestMatcherInterface()
132148

133149
$this->router->matchRequest(Request::create('/'));
134150
}
151+
152+
public function testDefaultLocaleIsPassedToGeneratorClass()
153+
{
154+
$this->loader->expects($this->once())
155+
->method('load')->with('routing.yml', null)
156+
->willReturn(new RouteCollection());
157+
158+
$router = new Router($this->loader, 'routing.yml', [
159+
'cache_dir' => null,
160+
], null, null, 'hr');
161+
162+
$generator = $router->getGenerator();
163+
164+
$this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator);
165+
166+
$p = new \ReflectionProperty($generator, 'defaultLocale');
167+
$p->setAccessible(true);
168+
169+
$this->assertSame('hr', $p->getValue($generator));
170+
}
171+
172+
public function testDefaultLocaleIsPassedToCompiledGeneratorCacheClass()
173+
{
174+
$this->loader->expects($this->once())
175+
->method('load')->with('routing.yml', null)
176+
->willReturn(new RouteCollection());
177+
178+
$router = new Router($this->loader, 'routing.yml', [
179+
'cache_dir' => $this->cacheDir,
180+
], null, null, 'hr');
181+
182+
$generator = $router->getGenerator();
183+
184+
$this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator);
185+
186+
$p = new \ReflectionProperty($generator, 'defaultLocale');
187+
$p->setAccessible(true);
188+
189+
$this->assertSame('hr', $p->getValue($generator));
190+
}
191+
192+
/**
193+
* @group legacy
194+
*/
195+
public function testDefaultLocaleIsPassedToNotCompiledGeneratorCacheClass()
196+
{
197+
$this->loader->expects($this->once())
198+
->method('load')->with('routing.yml', null)
199+
->willReturn(new RouteCollection());
200+
201+
$router = new Router($this->loader, 'routing.yml', [
202+
'cache_dir' => $this->cacheDir,
203+
'generator_class' => 'Symfony\Component\Routing\Generator\UrlGenerator',
204+
], null, null, 'hr');
205+
206+
$generator = $router->getGenerator();
207+
208+
$this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator);
209+
210+
$p = new \ReflectionProperty($generator, 'defaultLocale');
211+
$p->setAccessible(true);
212+
213+
$this->assertSame('hr', $p->getValue($generator));
214+
}
135215
}

0 commit comments

Comments
 (0)