[FrameworkBundle] Set the kernel.name properly after a cache warmup
This commit is contained in:
parent
5a9c1b5a0f
commit
1438b9a067
@ -144,9 +144,18 @@ EOF
|
||||
}
|
||||
|
||||
// fix references to kernel/container related classes
|
||||
$search = $tempKernel->getName().ucfirst($tempKernel->getEnvironment());
|
||||
$replace = $realKernel->getName().ucfirst($realKernel->getEnvironment());
|
||||
foreach (Finder::create()->files()->name($search.'*')->in($warmupDir) as $file) {
|
||||
$fileSearch = $tempKernel->getName().ucfirst($tempKernel->getEnvironment()).'*';
|
||||
$search = array(
|
||||
$tempKernel->getName().ucfirst($tempKernel->getEnvironment()),
|
||||
sprintf('\'kernel.name\' => \'%s\'', $tempKernel->getName()),
|
||||
sprintf('key="kernel.name">%s<', $tempKernel->getName()),
|
||||
);
|
||||
$replace = array(
|
||||
$realKernel->getName().ucfirst($realKernel->getEnvironment()),
|
||||
sprintf('\'kernel.name\' => \'%s\'', $realKernel->getName()),
|
||||
sprintf('key="kernel.name">%s<', $realKernel->getName()),
|
||||
);
|
||||
foreach (Finder::create()->files()->name($fileSearch)->in($warmupDir) as $file) {
|
||||
$content = str_replace($search, $replace, file_get_contents($file));
|
||||
file_put_contents(str_replace($search, $replace, $file), $content);
|
||||
unlink($file);
|
||||
|
@ -83,5 +83,6 @@ class CacheClearCommandTest extends TestCase
|
||||
}
|
||||
}
|
||||
$this->assertTrue($found, 'Kernel file should present as resource');
|
||||
$this->assertRegExp(sprintf('/\'kernel.name\'\s*=>\s*\'%s\'/', $this->kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user