mixin/polyfill.php - Import. Update comments.
[civicrm-core.git] / Civi / Test / CiviTestListenerPHPUnit7.php
index 42161cb12b0d90b607bb99d19b5106a75e58d49e..97c122081a8310dcb994613c03fbde7bf1917e53 100644 (file)
@@ -57,9 +57,24 @@ class CiviTestListenerPHPUnit7 implements \PHPUnit\Framework\TestListener {
     else {
       $this->tx = NULL;
     }
+
+    if ($this->isCiviTest($test) || $test instanceof \CiviUnitTestCase) {
+      \Civi\Test::eventChecker()->start($test);
+    }
   }
 
   public function endTest(\PHPUnit\Framework\Test $test, float $time): void {
+    $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;
@@ -73,6 +88,10 @@ class CiviTestListenerPHPUnit7 implements \PHPUnit\Framework\TestListener {
       error_reporting(E_ALL & ~E_NOTICE);
       $this->errorScope = NULL;
     }
+
+    if ($exception) {
+      throw $exception;
+    }
   }
 
   /**