10000 Merge branch '5.4' into 6.3 · symfony/symfony@756d103 · GitHub
[go: up one dir, main page]

Skip to content

Commit 756d103

Browse files
Merge branch '5.4' into 6.3
* 5.4: [FrameworkBundle] Always use buildDir as `ConfigBuilderGenerator` outputDir
2 parents dab32f6 + f8e2aa2 commit 756d103

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(KernelInterface $kernel, LoggerInterface $logger = n
4242
*/
4343
public function warmUp(string $cacheDir): array
4444
{
45-
$generator = new ConfigBuilderGenerator($cacheDir);
45+
$generator = new ConfigBuilderGenerator($this->kernel->getBuildDir());
4646

4747
foreach ($this->kernel->getBundles() as $bundle) {
4848
$extension = $bundle->getContainerExtension();
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
13+
14+
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer;
15+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
16+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
17+
use Symfony\Component\Config\Loader\LoaderInterface;
18+
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\Component\HttpKernel\Kernel;
20+
21+
class ConfigBuilderCacheWarmerTest extends TestCase
22+
{
23+
private $varDir;
24+
25+
protected function setUp(): void
26+
{
27+
$this->varDir = sys_get_temp_dir().'/'.uniqid();
28+
$fs = new Filesystem();
29+
$fs->mkdir($this->varDir);
30+
}
31+
32+
protected function tearDown(): void
33+
{
34+
$fs = new Filesystem();
35+
$fs->remove($this->varDir);
36+
unset($this->varDir);
37+
}
38+
39+
public function testBuildDirIsUsedAsConfigBuilderOutputDir()
40+
{
41+
$kernel = new class($this->varDir) extends Kernel {
42+
private $varDir;
43+
44+
public function __construct(string $varDir)
45+
{
46+
parent::__construct('test', false);
47+
48+
$this->varDir = $varDir;
49+
}
50+
51+
public function registerBundles(): iterable
52+
{
53+
yield new FrameworkBundle();
54+
}
55+
56+
public function getBuildDir(): string
57+
{
58+
return $this->varDir.'/build';
59+
}
60+
61+
public function getCacheDir(): string
62+
{
63+
return $this->varDir.'/cache';
64+
}
65+
66+
public function registerContainerConfiguration(LoaderInterface $loader)
67+
{
68+
}
69+
};
70+
$kernel->boot();
71+
72+
$warmer = new ConfigBuilderCacheWarmer($kernel);
73+
$warmer->warmUp($kernel->getCacheDir());
74+
75+
self::assertDirectoryExists($kernel->getBuildDir().'/Symfony');
76+
self::assertDirectoryDoesNotExist($kernel->getCacheDir().'/Symfony');
77+
}
78+
}

0 commit comments

Comments
 (0)
0