From e97aa1538d2ee3ec2ffcdeba23d6be91464cb8ba Mon Sep 17 00:00:00 2001
From: Ghislain Loas <gloas@afi-sa.fr>
Date: Wed, 30 Aug 2023 12:51:41 +0000
Subject: [PATCH] Test phpunit options for memory leak

---
 .../modules/AbstractControllerTestCase.php     | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php
index 671d536a1b4..15fe863b9cf 100644
--- a/tests/application/modules/AbstractControllerTestCase.php
+++ b/tests/application/modules/AbstractControllerTestCase.php
@@ -181,21 +181,23 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe
   }
 
 
+  public function cleanMemory() {
+    foreach ((new \ReflectionObject($this))->getProperties() as $prop) {
+      if ($prop->isStatic() || strpos($prop->getDeclaringClass()->getName(), 'PHPUnit') === 0)
+        continue;
+      unset($this->{$prop->getName()});
+    }
+  }
+
+
   public function tearDown() {
     new TearDown($this->_storm_default_to_volatile,
                  $this->_registry_sql,
                  $this->_registry_cfg);
 
     $this->_queryTearDown();
+    $this->cleanMemory();
     $this->_printMemory();
-     foreach ((new \ReflectionObject($this))->getProperties() as $prop) {
-
-
-                if ($prop->isStatic() || strpos($prop->getDeclaringClass()->getName(), 'PHPUnit\\') === 0) {
-                    continue;
-                }
-                unset($this->{$prop->getName()});
-            }
   }
 
 
-- 
GitLab