From 8bfdcdb6379741dc6d8e836deb8937d25f0f3811 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Mon, 13 Aug 2018 12:26:26 +0200 Subject: [PATCH 1/9] Free some memory in unit tests --- lib/Cake/TestSuite/ControllerTestCase.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index ff4adfb58..798f22bcb 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -418,4 +418,18 @@ abstract class ControllerTestCase extends CakeTestCase { return $this->controller; } +/** + * Unsets some properties to free memory. + * + * @return void + */ + public function tearDown() { + parent::tearDown(); + unset($this->contents); + unset($this->controller); + unset($this->headers); + unset($this->result); + unset($this->view); + unset($this->vars); + } } From dbbc8400b6d24d26f0de308e8b6677601af2a1cf Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Mon, 13 Aug 2018 13:09:22 +0200 Subject: [PATCH 2/9] Free some memory in unit tests --- lib/Cake/TestSuite/CakeTestCase.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 56fefb487..aaa40b87a 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -84,6 +84,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { $result = parent::run($result); if (!empty($this->fixtureManager)) { $this->fixtureManager->unload($this); + unset($this->fixtureManager); + unset($this->fixtures); } for ($i = ob_get_level(); $i < $level; ++$i) { @@ -164,6 +166,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { if (isset($_GET['debug']) && $_GET['debug']) { ob_flush(); } + unset($this->_configure); + unset($this->_pathRestore); } /** From b45fe026f5aa627d2e6354aa6196a10fe81c8169 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Mon, 13 Aug 2018 14:20:29 +0200 Subject: [PATCH 3/9] Unset more properties to free more memory --- lib/Cake/TestSuite/CakeTestCase.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index aaa40b87a..2f75ea6a5 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -84,8 +84,6 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { $result = parent::run($result); if (!empty($this->fixtureManager)) { $this->fixtureManager->unload($this); - unset($this->fixtureManager); - unset($this->fixtures); } for ($i = ob_get_level(); $i < $level; ++$i) { @@ -166,6 +164,9 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { if (isset($_GET['debug']) && $_GET['debug']) { ob_flush(); } + unset($this->db); + unset($this->fixtureManager); + unset($this->fixtures); unset($this->_configure); unset($this->_pathRestore); } From cb23bf922346e2120b36d4cd73f7609d209b726a Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Mon, 13 Aug 2018 14:38:54 +0200 Subject: [PATCH 4/9] Remove whitespace --- lib/Cake/TestSuite/CakeTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 2f75ea6a5..f99b5b618 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -166,7 +166,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { } unset($this->db); unset($this->fixtureManager); - unset($this->fixtures); + unset($this->fixtures); unset($this->_configure); unset($this->_pathRestore); } From 727aac1713d73d28e65da914b94c385826f3c0d6 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Mon, 13 Aug 2018 15:06:19 +0200 Subject: [PATCH 5/9] Move unset to the proper place --- lib/Cake/TestSuite/CakeTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index f99b5b618..beabf30b8 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -84,6 +84,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { $result = parent::run($result); if (!empty($this->fixtureManager)) { $this->fixtureManager->unload($this); + unset($this->fixtureManager); + unset($this->fixtures); } for ($i = ob_get_level(); $i < $level; ++$i) { @@ -165,8 +167,6 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { ob_flush(); } unset($this->db); - unset($this->fixtureManager); - unset($this->fixtures); unset($this->_configure); unset($this->_pathRestore); } From 0e02af091a2bad4c25b57fab4b037fe9402d4579 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Mon, 13 Aug 2018 15:28:10 +0200 Subject: [PATCH 6/9] Move unset to the proper place --- lib/Cake/TestSuite/CakeTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index beabf30b8..77810821f 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -86,6 +86,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { $this->fixtureManager->unload($this); unset($this->fixtureManager); unset($this->fixtures); + unset($this->db); } for ($i = ob_get_level(); $i < $level; ++$i) { @@ -166,7 +167,6 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { if (isset($_GET['debug']) && $_GET['debug']) { ob_flush(); } - unset($this->db); unset($this->_configure); unset($this->_pathRestore); } From f5bf22e1e328ec60cd6bc36cdd5dcc270e89d5f8 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Mon, 13 Aug 2018 17:13:47 +0200 Subject: [PATCH 7/9] Do not unset $this->fixtures --- lib/Cake/TestSuite/CakeTestCase.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 77810821f..a0b41f863 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -85,7 +85,6 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { if (!empty($this->fixtureManager)) { $this->fixtureManager->unload($this); unset($this->fixtureManager); - unset($this->fixtures); unset($this->db); } From e56452b2c54381601cab17aac3eb013438a3ce8c Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Tue, 14 Aug 2018 12:31:58 +0200 Subject: [PATCH 8/9] Improve code style --- lib/Cake/TestSuite/CakeTestCase.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index a0b41f863..359700406 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -84,8 +84,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { $result = parent::run($result); if (!empty($this->fixtureManager)) { $this->fixtureManager->unload($this); - unset($this->fixtureManager); - unset($this->db); + unset($this->fixtureManager, $this->db); } for ($i = ob_get_level(); $i < $level; ++$i) { @@ -166,8 +165,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { if (isset($_GET['debug']) && $_GET['debug']) { ob_flush(); } - unset($this->_configure); - unset($this->_pathRestore); + unset($this->_configure, $this->_pathRestore); } /** From a05c09c1f43b8076caee015ff4ab7ea863807499 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Tue, 14 Aug 2018 12:33:49 +0200 Subject: [PATCH 9/9] Improve code style --- lib/Cake/TestSuite/ControllerTestCase.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 798f22bcb..f891f35da 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -425,11 +425,13 @@ abstract class ControllerTestCase extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - unset($this->contents); - unset($this->controller); - unset($this->headers); - unset($this->result); - unset($this->view); - unset($this->vars); + unset( + $this->contents, + $this->controller, + $this->headers, + $this->result, + $this->view, + $this->vars + ); } }