4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 namespace api\v
4\Traits
;
21 trait OptionCleanupTrait
{
26 protected $optionGroupMaxId;
31 protected $optionValueMaxId;
33 public function setUp(): void
{
34 $this->optionGroupMaxId
= \CRM_Core_DAO
::singleValueQuery('SELECT MAX(id) FROM civicrm_option_group');
35 $this->optionValueMaxId
= \CRM_Core_DAO
::singleValueQuery('SELECT MAX(id) FROM civicrm_option_value');
38 public function tearDown(): void
{
39 if ($this->optionValueMaxId
) {
40 \CRM_Core_DAO
::executeQuery('DELETE FROM civicrm_option_value WHERE id > ' . $this->optionValueMaxId
);
42 if ($this->optionGroupMaxId
) {
43 \CRM_Core_DAO
::executeQuery('DELETE FROM civicrm_option_group WHERE id > ' . $this->optionGroupMaxId
);