Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 5.4:
  [FrameworkBundle] Always use buildDir as `ConfigBuilderGenerator` outputDir
  • Loading branch information
nicolas-grekas committed Sep 27, 2023
2 parents c7940e1 + 63e4ad1 commit f1e2c3a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CacheWarmer/ConfigBuilderCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(KernelInterface $kernel, LoggerInterface $logger = n
*/
public function warmUp(string $cacheDir): array
{
$generator = new ConfigBuilderGenerator($cacheDir);
$generator = new ConfigBuilderGenerator($this->kernel->getBuildDir());

foreach ($this->kernel->getBundles() as $bundle) {
$extension = $bundle->getContainerExtension();
Expand Down
78 changes: 78 additions & 0 deletions Tests/CacheWarmer/ConfigBuilderCacheWarmerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;

use Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;

class ConfigBuilderCacheWarmerTest extends TestCase
{
private $varDir;

protected function setUp(): void
{
$this->varDir = sys_get_temp_dir().'/'.uniqid();
$fs = new Filesystem();
$fs->mkdir($this->varDir);
}

protected function tearDown(): void
{
$fs = new Filesystem();
$fs->remove($this->varDir);
unset($this->varDir);
}

public function testBuildDirIsUsedAsConfigBuilderOutputDir()
{
$kernel = new class($this->varDir) extends Kernel {
private $varDir;

public function __construct(string $varDir)
{
parent::__construct('test', false);

$this->varDir = $varDir;
}

public function registerBundles(): iterable
{
yield new FrameworkBundle();
}

public function getBuildDir(): string
{
return $this->varDir.'/build';
}

public function getCacheDir(): string
{
return $this->varDir.'/cache';
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
}
};
$kernel->boot();

$warmer = new ConfigBuilderCacheWarmer($kernel);
$warmer->warmUp($kernel->getCacheDir());

self::assertDirectoryExists($kernel->getBuildDir().'/Symfony');
self::assertDirectoryDoesNotExist($kernel->getCacheDir().'/Symfony');
}
}

0 comments on commit f1e2c3a

Please sign in to comment.