From 211feef60d7aa69bcda98d72e633939a51ec7ee5 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 10 May 2021 17:18:58 -0400 Subject: [PATCH] APIv4 - Add test to ensure custom tables are deleted --- tests/phpunit/api/v4/Action/CustomFieldAlterTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/phpunit/api/v4/Action/CustomFieldAlterTest.php b/tests/phpunit/api/v4/Action/CustomFieldAlterTest.php index 1e58fc0b17..76741ebf58 100644 --- a/tests/phpunit/api/v4/Action/CustomFieldAlterTest.php +++ b/tests/phpunit/api/v4/Action/CustomFieldAlterTest.php @@ -162,6 +162,17 @@ class CustomFieldAlterTest extends BaseCustomValueTest { ->execute(); } + // Check that custom table exists and is then removed when group is deleted + $this->assertNotNull(\CRM_Core_DAO::singleValueQuery("SHOW TABLES LIKE '{$customGroup['table_name']}';")); + + CustomField::delete(FALSE) + ->addWhere('custom_group_id', '=', $customGroup['id']) + ->execute(); + CustomGroup::delete(FALSE) + ->addWhere('id', '=', $customGroup['id']) + ->execute(); + // The table should be gone + $this->assertNull(\CRM_Core_DAO::singleValueQuery("SHOW TABLES LIKE '{$customGroup['table_name']}';")); } } -- 2.25.1