mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 19:48:49 +02:00
N°8910 - Upgrade Symfony packages (#811)
This commit is contained in:
@@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
@@ -82,6 +83,18 @@ abstract class KernelTestCase extends TestCase
|
||||
static::$kernel = $kernel;
|
||||
static::$booted = true;
|
||||
|
||||
// If the cache warmer is registered, it means that the cache has been
|
||||
// warmed up, so the current container is not fresh anymore. Let's
|
||||
// reboot a fresh one.
|
||||
if (self::getContainer()->initialized('cache_warmer')) {
|
||||
static::ensureKernelShutdown();
|
||||
|
||||
$kernel = static::createKernel($options);
|
||||
$kernel->boot();
|
||||
static::$kernel = $kernel;
|
||||
static::$booted = true;
|
||||
}
|
||||
|
||||
return static::$kernel;
|
||||
}
|
||||
|
||||
@@ -135,6 +148,11 @@ abstract class KernelTestCase extends TestCase
|
||||
static::$kernel->boot();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$httpCacheDir = null;
|
||||
if ($container->has('http_cache')) {
|
||||
$httpCacheDir = static::$kernel->getCacheDir().'/http_cache';
|
||||
}
|
||||
|
||||
if ($container->has('services_resetter')) {
|
||||
// Instantiate the service because Container::reset() only resets services that have been used
|
||||
$container->get('services_resetter');
|
||||
@@ -146,6 +164,10 @@ abstract class KernelTestCase extends TestCase
|
||||
if ($container instanceof ResetInterface) {
|
||||
$container->reset();
|
||||
}
|
||||
|
||||
if (null !== $httpCacheDir && is_dir($httpCacheDir)) {
|
||||
(new Filesystem())->remove($httpCacheDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user