From 82e1689e09d2c92044345e0f89f2e31f15d841a6 Mon Sep 17 00:00:00 2001 From: Nileema Date: Tue, 27 May 2014 21:06:49 +0530 Subject: [PATCH] HR-377 Fix to custom_data_entities() function not to have entities while related component is disabled --- .../phpunit/api/v3/SyntaxConformanceTest.php | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 69c946a4b8..3793e52431 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -48,6 +48,25 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { protected $_entity; + /** Map custom group entities to civicrm components */ + static $componentMap = array( + 'Contact' => NULL, + 'Individual' => NULL, + 'Household' => NULL, + 'Organization' => NULL, + 'Contribution' => 'CiviContribute', + 'Membership' => 'CiviMember', + 'Participant' => 'CiviEvent', + 'Group' => NULL, + 'Relationship' => NULL, + 'Event' => 'CiviEvent', + 'Case' => 'CiviCase', + 'Activity' => NULL, + 'Pledge' => 'CiviPledge', + 'Grant' => 'CiviGrant', + 'Address' => NULL, + ); + /* they are two types of missing APIs: - Those that are to be implemented (in some future version when someone steps in -hint hint-). List the entities in toBeImplemented[ {$action} ] @@ -151,16 +170,19 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * @return array */ public static function custom_data_entities() { - $entities = CRM_Core_BAO_CustomQuery::$extendsMap; - $customDataEntities = array(); + $enableComponents = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array()); + $entities = CRM_Core_BAO_CustomQuery::$extendsMap; + $components = self::$componentMap; + $customDataEntities = array(); $invalidEntities = array('Individual', 'Organization', 'Household'); $entitiesToFix = array('Case', 'Relationship'); - foreach ($entities as $entityName => $entity ) { - if(!in_array($entityName, $invalidEntities) - && !in_array($entityName, $entitiesToFix)) { - $customDataEntities[] = array($entityName ); - } - } + foreach ($entities as $entityName => $entity ) { + if(!in_array($entityName, $invalidEntities) + && !in_array($entityName, $entitiesToFix) + && (!empty($components[$entityName]) && in_array($components[$entityName], $enableComponents) || $components[$entityName] == NULL)) { + $customDataEntities[] = array($entityName ); + } + } return $customDataEntities; } -- 2.25.1