Merge pull request #24109 from yashodha/reports_improvements
[civicrm-core.git] / Civi / Test / CiviTestListener.php
index 8f4c21d7a4de45833a2487ced64163f893361aec..6e3b4cdc08c9d5561d64384eef4f9f40de528516 100644 (file)
@@ -65,9 +65,24 @@ else {
       else {
         $this->tx = NULL;
       }
+
+      if ($this->isCiviTest($test) || $test instanceof \CiviUnitTestCase) {
+        \Civi\Test::eventChecker()->start($test);
+      }
     }
 
     public function endTest(\PHPUnit\Framework\Test $test, $time) {
+      $exception = NULL;
+
+      if ($this->isCiviTest($test) || $test instanceof \CiviUnitTestCase) {
+        try {
+          \Civi\Test::eventChecker()->stop($test);
+        }
+        catch (\Exception $e) {
+          $exception = $e;
+        }
+      }
+
       if ($test instanceof TransactionalInterface) {
         $this->tx->rollback()->commit();
         $this->tx = NULL;
@@ -81,6 +96,10 @@ else {
         error_reporting(E_ALL & ~E_NOTICE);
         $this->errorScope = NULL;
       }
+
+      if ($exception) {
+        throw $exception;
+      }
     }
 
     /**