From 824bdea1a1678248c5d6a1a696dd9b0ddde12a5d Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 29 Dec 2015 17:59:38 +1300 Subject: [PATCH] Add cleanup for option groups to quick cleanup Change-Id: Iaa10e26dbbe54f7af228a022d74b48f9107528e8 --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 1400c9bdff..a6f4e213ef 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2529,7 +2529,9 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { } /** - * @param $tablesToTruncate + * Quick clean by emptying tables created for the test. + * + * @param array $tablesToTruncate * @param bool $dropCustomValueTables * @throws \Exception */ @@ -2538,6 +2540,12 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { throw new Exception("CiviUnitTestCase: quickCleanup() is not compatible with useTransaction()"); } if ($dropCustomValueTables) { + $optionGroupResult = CRM_Core_DAO::executeQuery('SELECT option_group_id FROM civicrm_custom_field'); + while ($optionGroupResult->fetch()) { + if (!empty($optionGroupResult->option_group_id)) { + CRM_Core_DAO::executeQuery('DELETE FROM civicrm_option_group WHERE id = ' . $optionGroupResult->option_group_id); + } + } $tablesToTruncate[] = 'civicrm_custom_group'; $tablesToTruncate[] = 'civicrm_custom_field'; } -- 2.25.1