Merge pull request #19614 from eileenmcnaughton/dispatch
[civicrm-core.git] / Civi / Test / CiviTestListener.php
index e32d9b45d28888a925824bb608a5de85bd944799..af5c2cc2680a1bf8ff2bfc410cfb1d322cc9b789 100644 (file)
@@ -7,6 +7,9 @@ if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Ve
   // Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
   // gets defined without executing the code before it and so the definition is not properly conditional)
 }
+elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '>=')) {
+  class_alias('Civi\Test\CiviTestListenerPHPUnit7', 'Civi\Test\CiviTestListener');
+}
 else {
 
   /**
@@ -22,10 +25,6 @@ else {
    * @see HookInterface
    */
   class CiviTestListener extends \PHPUnit\Framework\BaseTestListener {
-    /**
-     * @var \CRM_Core_TemporaryErrorScope
-     */
-    private $errorScope;
 
     /**
      * @var array
@@ -52,7 +51,6 @@ else {
     public function startTest(\PHPUnit\Framework\Test $test) {
       if ($this->isCiviTest($test)) {
         error_reporting(E_ALL);
-        $this->errorScope = \CRM_Core_TemporaryErrorScope::useException();
       }
 
       if ($test instanceof HeadlessInterface) {
@@ -82,6 +80,7 @@ else {
       if ($test instanceof HookInterface) {
         \CRM_Utils_Hook::singleton()->reset();
       }
+      \CRM_Utils_Time::resetTime();
       if ($this->isCiviTest($test)) {
         error_reporting(E_ALL & ~E_NOTICE);
         $this->errorScope = NULL;