CiviTestListener - Provide a variable to identify the active test
authorTim Otten <totten@civicrm.org>
Thu, 20 May 2021 23:41:59 +0000 (16:41 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 26 May 2021 23:52:19 +0000 (16:52 -0700)
Civi/Test/CiviTestListener.php
Civi/Test/CiviTestListenerPHPUnit7.php
Civi/Test/Legacy/CiviTestListener.php

index af5c2cc2680a1bf8ff2bfc410cfb1d322cc9b789..c8c838bc05120181c8b766ef9984db3db7039e19 100644 (file)
@@ -51,6 +51,7 @@ else {
     public function startTest(\PHPUnit\Framework\Test $test) {
       if ($this->isCiviTest($test)) {
         error_reporting(E_ALL);
+        $GLOBALS['CIVICRM_TEST_CASE'] = $test;
       }
 
       if ($test instanceof HeadlessInterface) {
@@ -82,6 +83,7 @@ else {
       }
       \CRM_Utils_Time::resetTime();
       if ($this->isCiviTest($test)) {
+        unset($GLOBALS['CIVICRM_TEST_CASE']);
         error_reporting(E_ALL & ~E_NOTICE);
         $this->errorScope = NULL;
       }
index 1efbacce135d8a06ebdac5c4ef20ed9f61aa62ee..b791e4caf17cda3c7bbc00cb7c2e1f8a4807e059 100644 (file)
@@ -43,6 +43,7 @@ class CiviTestListenerPHPUnit7 implements \PHPUnit\Framework\TestListener {
   public function startTest(\PHPUnit\Framework\Test $test): void {
     if ($this->isCiviTest($test)) {
       error_reporting(E_ALL);
+      $GLOBALS['CIVICRM_TEST_CASE'] = $test;
     }
 
     if ($test instanceof HeadlessInterface) {
@@ -74,6 +75,7 @@ class CiviTestListenerPHPUnit7 implements \PHPUnit\Framework\TestListener {
     }
     \CRM_Utils_Time::resetTime();
     if ($this->isCiviTest($test)) {
+      unset($GLOBALS['CIVICRM_TEST_CASE']);
       error_reporting(E_ALL & ~E_NOTICE);
       $this->errorScope = NULL;
     }
index d7e3a1ad9d1c4fbb947cce9f4834037223481702..1bd0a705071bbc25284881d0f777a74dc2c3276c 100644 (file)
@@ -41,6 +41,7 @@ class CiviTestListener extends \PHPUnit_Framework_BaseTestListener {
   public function startTest(\PHPUnit_Framework_Test $test) {
     if ($this->isCiviTest($test)) {
       error_reporting(E_ALL);
+      $GLOBALS['CIVICRM_TEST_CASE'] = $test;
     }
 
     if ($test instanceof \Civi\Test\HeadlessInterface) {
@@ -71,6 +72,7 @@ class CiviTestListener extends \PHPUnit_Framework_BaseTestListener {
     }
     \CRM_Utils_Time::resetTime();
     if ($this->isCiviTest($test)) {
+      unset($GLOBALS['CIVICRM_TEST_CASE']);
       error_reporting(E_ALL & ~E_NOTICE);
       $this->errorScope = NULL;
     }