From 9107ede18c1bc5b07874de7bd1e4f61514acf83c Mon Sep 17 00:00:00 2001 From: Daniel Holmes Date: Tue, 3 May 2011 14:17:33 +1000 Subject: [PATCH 1/2] [FrameworkBundle][HttpKernel] added a default tearDown on the WebTestCase which will shut down the currently used kernel (if there is one) in Web functional tests --- .../Bundle/FrameworkBundle/Test/WebTestCase.php | 11 +++++++++++ src/Symfony/Component/HttpKernel/Kernel.php | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index 0a05839919..d835baa2b3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -150,4 +150,15 @@ 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 51ef6137e9..9daf001e36 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -292,6 +292,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. From 34b44a0ff1cebbadc726980b380f047d1d42d09d Mon Sep 17 00:00:00 2001 From: Daniel Holmes Date: Tue, 3 May 2011 15:00:01 +1000 Subject: [PATCH 2/2] [FrameworkBundle] fixed CS --- src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index d835baa2b3..ccfc458299 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -156,8 +156,7 @@ abstract class WebTestCase extends BaseWebTestCase */ protected function tearDown() { - if ($this->kernel !== null && $this->kernel->isBooted()) - { + if ($this->kernel !== null && $this->kernel->isBooted()) { $this->kernel->shutdown(); } }