[HttpKernel] reset kernel start time on reboot
This commit is contained in:
parent
c2f15afdc2
commit
b7feef00ae
@ -87,18 +87,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
$this->debug = (bool) $debug;
|
$this->debug = (bool) $debug;
|
||||||
$this->rootDir = $this->getRootDir();
|
$this->rootDir = $this->getRootDir();
|
||||||
$this->name = $this->getName();
|
$this->name = $this->getName();
|
||||||
|
|
||||||
if ($this->debug) {
|
|
||||||
$this->startTime = microtime(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
if ($this->debug) {
|
|
||||||
$this->startTime = microtime(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->booted = false;
|
$this->booted = false;
|
||||||
$this->container = null;
|
$this->container = null;
|
||||||
$this->requestStackSize = 0;
|
$this->requestStackSize = 0;
|
||||||
@ -110,6 +102,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
|
if ($this->debug) {
|
||||||
|
$this->startTime = microtime(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (true === $this->booted) {
|
if (true === $this->booted) {
|
||||||
if (!$this->requestStackSize && $this->resetServices) {
|
if (!$this->requestStackSize && $this->resetServices) {
|
||||||
if ($this->container->has('services_resetter')) {
|
if ($this->container->has('services_resetter')) {
|
||||||
|
@ -901,6 +901,21 @@ EOF;
|
|||||||
$this->assertEquals(1, ResettableService::$counter);
|
$this->assertEquals(1, ResettableService::$counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group time-sensitive
|
||||||
|
*/
|
||||||
|
public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel()
|
||||||
|
{
|
||||||
|
$kernel = $this->getKernelForTest(array('initializeBundles'), true);
|
||||||
|
$kernel->boot();
|
||||||
|
$preReBoot = $kernel->getStartTime();
|
||||||
|
|
||||||
|
sleep(3600); //Intentionally large value to detect if ClockMock ever breaks
|
||||||
|
$kernel->boot();
|
||||||
|
|
||||||
|
$this->assertGreaterThan($preReBoot, $kernel->getStartTime());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a mock for the BundleInterface.
|
* Returns a mock for the BundleInterface.
|
||||||
*
|
*
|
||||||
@ -970,10 +985,10 @@ EOF;
|
|||||||
return $kernel;
|
return $kernel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getKernelForTest(array $methods = array())
|
protected function getKernelForTest(array $methods = array(), $debug = false)
|
||||||
{
|
{
|
||||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
|
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
|
||||||
->setConstructorArgs(array('test', false))
|
->setConstructorArgs(array('test', $debug))
|
||||||
->setMethods($methods)
|
->setMethods($methods)
|
||||||
->getMock();
|
->getMock();
|
||||||
$p = new \ReflectionProperty($kernel, 'rootDir');
|
$p = new \ReflectionProperty($kernel, 'rootDir');
|
||||||
|
Reference in New Issue
Block a user