Преглед на файлове

[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

Daniel Holmes преди 14 години
родител
ревизия
9107ede18c
променени са 2 файла, в които са добавени 21 реда и са изтрити 0 реда
  1. 11 0
      src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php
  2. 10 0
      src/Symfony/Component/HttpKernel/Kernel.php

+ 11 - 0
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();
+        }
+    }
 }

+ 10 - 0
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.