From: eileen Date: Tue, 29 Dec 2015 04:59:38 +0000 (+1300) Subject: Add cleanup for option groups to quick cleanup X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0fff773f36c5d532f37ab7b2a004f9e326a6395f;p=civicrm-core.git Add cleanup for option groups to quick cleanup Change-Id: Iaa10e26dbbe54f7af228a022d74b48f9107528e8 --- diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index c7de801ff3..ccdc8fafba 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2566,7 +2566,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 */ @@ -2575,6 +2577,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'; }