diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index 0a05839919..ccfc458299 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -150,4 +150,14 @@ abstract class WebTestCase extends BaseWebTestCase isset($options['debug']) ? $options['debug'] : true ); } + + /** + * Shuts the kernel down if it was used in the test + */ + protected function tearDown() + { + if ($this->kernel !== null && $this->kernel->isBooted()) { + $this->kernel->shutdown(); + } + } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 797a09df05..22dfc1fa8f 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -296,6 +296,16 @@ abstract class Kernel implements KernelInterface { return $this->name; } + + /** + * Checks if the Kernel is currently booted. + * + * @return Boolean true if kernel is booted, false otherwise + */ + public function isBooted() + { + return $this->booted; + } /** * Gets the environment.