From 5136291914854fd5a78b8fb660d586b053c2547b Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 19 Feb 2018 15:17:10 +1300 Subject: [PATCH] Fix more entities to support custom fields (via api) --- api/v3/AclRole.php | 2 +- api/v3/CaseContact.php | 2 +- api/v3/ContributionProduct.php | 2 +- api/v3/ContributionSoft.php | 2 +- api/v3/Dashboard.php | 6 +- api/v3/DashboardContact.php | 2 +- api/v3/EntityBatch.php | 2 +- api/v3/EntityFinancialTrxn.php | 2 +- api/v3/Im.php | 2 +- api/v3/Job.php | 2 +- api/v3/LocationType.php | 2 +- api/v3/MailSettings.php | 2 +- api/v3/MailingAB.php | 2 +- api/v3/MailingComponent.php | 2 +- api/v3/MailingEventQueue.php | 2 +- api/v3/MappingField.php | 2 +- api/v3/MembershipLog.php | 2 +- api/v3/MembershipPayment.php | 2 +- api/v3/MessageTemplate.php | 2 +- api/v3/Navigation.php | 2 +- api/v3/Note.php | 2 +- api/v3/OpenID.php | 2 +- api/v3/OptionGroup.php | 2 +- api/v3/OptionValue.php | 2 +- api/v3/ParticipantStatusType.php | 2 +- api/v3/Premium.php | 2 +- api/v3/PrintLabel.php | 2 +- api/v3/Product.php | 2 +- api/v3/ReportInstance.php | 2 +- api/v3/RuleGroup.php | 2 +- api/v3/SavedSearch.php | 2 +- api/v3/SmsProvider.php | 2 +- api/v3/StateProvince.php | 2 +- .../phpunit/api/v3/SyntaxConformanceTest.php | 99 +++++++++++++++++-- 34 files changed, 122 insertions(+), 47 deletions(-) diff --git a/api/v3/AclRole.php b/api/v3/AclRole.php index b1708533b704..36f570df6065 100644 --- a/api/v3/AclRole.php +++ b/api/v3/AclRole.php @@ -40,7 +40,7 @@ * API result array */ function civicrm_api3_acl_role_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'AclRole'); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'EntityRole'); } /** diff --git a/api/v3/CaseContact.php b/api/v3/CaseContact.php index 4898d6308c4b..c121abc7dacc 100644 --- a/api/v3/CaseContact.php +++ b/api/v3/CaseContact.php @@ -39,7 +39,7 @@ * @return array */ function civicrm_api3_case_contact_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'CaseContact'); } /** diff --git a/api/v3/ContributionProduct.php b/api/v3/ContributionProduct.php index a372bf871d1f..86efc7bd9682 100644 --- a/api/v3/ContributionProduct.php +++ b/api/v3/ContributionProduct.php @@ -43,7 +43,7 @@ * @return array */ function civicrm_api3_contribution_product_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ContributionProduct'); } /** diff --git a/api/v3/ContributionSoft.php b/api/v3/ContributionSoft.php index 5c4daf3a94ad..aafe6023e622 100644 --- a/api/v3/ContributionSoft.php +++ b/api/v3/ContributionSoft.php @@ -41,7 +41,7 @@ * API result array */ function civicrm_api3_contribution_soft_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ContributionSoft'); } /** diff --git a/api/v3/Dashboard.php b/api/v3/Dashboard.php index cf5aae7b2f27..01c1e43cd11b 100644 --- a/api/v3/Dashboard.php +++ b/api/v3/Dashboard.php @@ -73,11 +73,7 @@ function _civicrm_api3_dashboard_create_spec(&$params) { * @return array */ function civicrm_api3_dashboard_get($params) { - // NEVER COPY THIS. No idea why a newish api would not use basic_get. - $bao = new CRM_Core_BAO_Dashboard(); - _civicrm_api3_dao_set_filter($bao, $params, TRUE); - $dashlets = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'Dashboard'); - return civicrm_api3_create_success($dashlets, $params, 'Dashboard', 'get', $bao); + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } /** diff --git a/api/v3/DashboardContact.php b/api/v3/DashboardContact.php index e67fef5f6eb6..7a1d9b3711c2 100644 --- a/api/v3/DashboardContact.php +++ b/api/v3/DashboardContact.php @@ -51,7 +51,7 @@ function civicrm_api3_dashboard_contact_create($params) { if ($errors !== NULL) { return $errors; } - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'DashboardContact'); } /** diff --git a/api/v3/EntityBatch.php b/api/v3/EntityBatch.php index 4418bce80c69..7dae97a0e371 100644 --- a/api/v3/EntityBatch.php +++ b/api/v3/EntityBatch.php @@ -66,7 +66,7 @@ function _civicrm_api3_entity_batch_create_spec(&$params) { * @return array */ function civicrm_api3_entity_batch_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'EntityBatch'); } /** diff --git a/api/v3/EntityFinancialTrxn.php b/api/v3/EntityFinancialTrxn.php index 0c0e7b1578ff..5ddd6c30a5d9 100644 --- a/api/v3/EntityFinancialTrxn.php +++ b/api/v3/EntityFinancialTrxn.php @@ -39,7 +39,7 @@ * @return array */ function civicrm_api3_entity_financial_trxn_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'EntityFinancialTrxn'); } /** diff --git a/api/v3/Im.php b/api/v3/Im.php index 7630989d4cb0..e78bf0481295 100644 --- a/api/v3/Im.php +++ b/api/v3/Im.php @@ -39,7 +39,7 @@ * @return array */ function civicrm_api3_im_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'IM'); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Im'); } /** diff --git a/api/v3/Job.php b/api/v3/Job.php index 1d21b3496500..e9e9306691d4 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -58,7 +58,7 @@ function _civicrm_api3_job_create_spec(&$params) { * @return array */ function civicrm_api3_job_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Job'); } /** diff --git a/api/v3/LocationType.php b/api/v3/LocationType.php index 49b124f0d3aa..bd419d871177 100644 --- a/api/v3/LocationType.php +++ b/api/v3/LocationType.php @@ -45,7 +45,7 @@ function civicrm_api3_location_type_create($params) { $params['display_name'] = $params['name']; } - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'LocationType'); } /** diff --git a/api/v3/MailSettings.php b/api/v3/MailSettings.php index 54743ad1796a..112a175e9fbd 100644 --- a/api/v3/MailSettings.php +++ b/api/v3/MailSettings.php @@ -41,7 +41,7 @@ * API result array. */ function civicrm_api3_mail_settings_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MailSettings'); } /** diff --git a/api/v3/MailingAB.php b/api/v3/MailingAB.php index e0ca07424afe..542ced9213fe 100644 --- a/api/v3/MailingAB.php +++ b/api/v3/MailingAB.php @@ -50,7 +50,7 @@ function _civicrm_api3_mailing_a_b_create_spec(&$spec) { * API Success Array */ function civicrm_api3_mailing_a_b_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MailingAB'); } /** diff --git a/api/v3/MailingComponent.php b/api/v3/MailingComponent.php index 811d3b5b217f..e05491edceac 100644 --- a/api/v3/MailingComponent.php +++ b/api/v3/MailingComponent.php @@ -41,7 +41,7 @@ * API result array. */ function civicrm_api3_mailing_component_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Component'); } diff --git a/api/v3/MailingEventQueue.php b/api/v3/MailingEventQueue.php index 8592a8d36466..a1a3f8de84a0 100644 --- a/api/v3/MailingEventQueue.php +++ b/api/v3/MailingEventQueue.php @@ -50,7 +50,7 @@ function civicrm_api3_mailing_event_queue_create($params) { array('job_id', 'contact_id'), FALSE ); - return _civicrm_api3_basic_create('CRM_Mailing_Event_BAO_Queue', $params); + return _civicrm_api3_basic_create('CRM_Mailing_Event_BAO_Queue', $params, 'Queue'); } /** diff --git a/api/v3/MappingField.php b/api/v3/MappingField.php index 4dc877876260..88d257bc9c49 100644 --- a/api/v3/MappingField.php +++ b/api/v3/MappingField.php @@ -40,7 +40,7 @@ * @return array */ function civicrm_api3_mapping_field_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MappingField'); } /** diff --git a/api/v3/MembershipLog.php b/api/v3/MembershipLog.php index 89d58c442c52..cd5dd6ad7bb2 100644 --- a/api/v3/MembershipLog.php +++ b/api/v3/MembershipLog.php @@ -41,7 +41,7 @@ * API result array. */ function civicrm_api3_membership_log_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MembershipLog'); } /** diff --git a/api/v3/MembershipPayment.php b/api/v3/MembershipPayment.php index 05277f11d621..3f13154fb0ab 100644 --- a/api/v3/MembershipPayment.php +++ b/api/v3/MembershipPayment.php @@ -42,7 +42,7 @@ * API result array. */ function civicrm_api3_membership_payment_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MembershipPayment'); } /** diff --git a/api/v3/MessageTemplate.php b/api/v3/MessageTemplate.php index a8557538a8aa..8c4c7554184d 100644 --- a/api/v3/MessageTemplate.php +++ b/api/v3/MessageTemplate.php @@ -40,7 +40,7 @@ * @throws \API_Exception */ function civicrm_api3_message_template_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MessageTemplate'); } /** diff --git a/api/v3/Navigation.php b/api/v3/Navigation.php index e4070ef16486..fb040d2c65d5 100644 --- a/api/v3/Navigation.php +++ b/api/v3/Navigation.php @@ -109,7 +109,7 @@ function _civicrm_api3_navigation_create_spec(&$params) { */ function civicrm_api3_navigation_create($params) { civicrm_api3_verify_one_mandatory($params, NULL, array('name', 'label')); - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Navigation'); } /** diff --git a/api/v3/Note.php b/api/v3/Note.php index 70f73c5b2fad..d08d6e37f020 100644 --- a/api/v3/Note.php +++ b/api/v3/Note.php @@ -44,7 +44,7 @@ * API result array */ function civicrm_api3_note_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Note'); } /** diff --git a/api/v3/OpenID.php b/api/v3/OpenID.php index cff85e292836..d338a2429041 100644 --- a/api/v3/OpenID.php +++ b/api/v3/OpenID.php @@ -40,7 +40,7 @@ * API result array */ function civicrm_api3_open_i_d_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'OpenID'); } /** diff --git a/api/v3/OptionGroup.php b/api/v3/OptionGroup.php index 58942efa592d..e20cced41fda 100644 --- a/api/v3/OptionGroup.php +++ b/api/v3/OptionGroup.php @@ -53,7 +53,7 @@ function civicrm_api3_option_group_get($params) { * @return array */ function civicrm_api3_option_group_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'OptionGroup'); } /** diff --git a/api/v3/OptionValue.php b/api/v3/OptionValue.php index a10cb899c97e..e83333467051 100644 --- a/api/v3/OptionValue.php +++ b/api/v3/OptionValue.php @@ -42,7 +42,7 @@ * API result array */ function civicrm_api3_option_value_get($params) { - return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'OptionValue'); } /** diff --git a/api/v3/ParticipantStatusType.php b/api/v3/ParticipantStatusType.php index 22ea6081b962..ea74bbf59308 100644 --- a/api/v3/ParticipantStatusType.php +++ b/api/v3/ParticipantStatusType.php @@ -45,7 +45,7 @@ * participant_status array */ function civicrm_api3_participant_status_type_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ParticipantStatusType'); } /** diff --git a/api/v3/Premium.php b/api/v3/Premium.php index 5f3a8f41eaa4..066e6e9a9bf7 100644 --- a/api/v3/Premium.php +++ b/api/v3/Premium.php @@ -44,7 +44,7 @@ * @return array */ function civicrm_api3_premium_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Premium'); } /** diff --git a/api/v3/PrintLabel.php b/api/v3/PrintLabel.php index 54ad27ccc2ac..c436a853c2ad 100644 --- a/api/v3/PrintLabel.php +++ b/api/v3/PrintLabel.php @@ -39,7 +39,7 @@ * @return array */ function civicrm_api3_print_label_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'PrintLabel'); } /** diff --git a/api/v3/Product.php b/api/v3/Product.php index e862b28449a2..a60e19bad037 100644 --- a/api/v3/Product.php +++ b/api/v3/Product.php @@ -43,7 +43,7 @@ * @return array */ function civicrm_api3_product_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Product'); } /** diff --git a/api/v3/ReportInstance.php b/api/v3/ReportInstance.php index 97679be0ed88..cb8c618e550d 100644 --- a/api/v3/ReportInstance.php +++ b/api/v3/ReportInstance.php @@ -53,7 +53,7 @@ function civicrm_api3_report_instance_get($params) { * API result array */ function civicrm_api3_report_instance_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ReportInstance'); } /** diff --git a/api/v3/RuleGroup.php b/api/v3/RuleGroup.php index 68a0f9ef41a9..d8abd0a8b38f 100644 --- a/api/v3/RuleGroup.php +++ b/api/v3/RuleGroup.php @@ -43,7 +43,7 @@ * API result array */ function civicrm_api3_rule_group_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'RuleGroup'); } /** diff --git a/api/v3/SavedSearch.php b/api/v3/SavedSearch.php index e32c258e3528..ec9538601db8 100644 --- a/api/v3/SavedSearch.php +++ b/api/v3/SavedSearch.php @@ -60,7 +60,7 @@ function civicrm_api3_saved_search_create($params) { } } - $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'SavedSearch'); _civicrm_api3_saved_search_result_cleanup($result); return $result; } diff --git a/api/v3/SmsProvider.php b/api/v3/SmsProvider.php index fc45ebb241e0..c445c4ed76af 100644 --- a/api/v3/SmsProvider.php +++ b/api/v3/SmsProvider.php @@ -39,7 +39,7 @@ * @return array */ function civicrm_api3_sms_provider_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Provider'); } /** diff --git a/api/v3/StateProvince.php b/api/v3/StateProvince.php index b07d41cb420c..2044cf98b3c7 100644 --- a/api/v3/StateProvince.php +++ b/api/v3/StateProvince.php @@ -42,7 +42,7 @@ * @throws \API_Exception */ function civicrm_api3_state_province_create($params) { - return _civicrm_api3_basic_create(_civicrm_api3_get_DAO(__FUNCTION__), $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_DAO(__FUNCTION__), $params, 'StateProvince'); } /** diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 2da495608408..042ec7e22bd6 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -267,12 +267,7 @@ public static function custom_data_entities() { * @return array */ public static function custom_data_incl_non_std_entities_get() { - $customDataEntities = self::custom_data_entities(); - $customDataEntities[] = ['UFGroup']; - $customDataEntities[] = ['PriceSet']; - $customDataEntities[] = ['PaymentToken']; - $customDataEntities[] = ['Mailing']; - return $customDataEntities; + return static::entities(static::toBeSkipped_custom_data_creatable(TRUE)); } /** @@ -371,6 +366,77 @@ public static function toBeSkipped_delete($sequential = FALSE) { return $entities; } + /** + * @param bool $sequential + * + * @return array + */ + public static function toBeSkipped_custom_data_creatable($sequential = FALSE) { + $entitiesWithout = array( + // Ones to fix. + 'CaseContact', + 'CustomField', + 'CustomGroup', + 'DashboardContact', + 'Domain', + 'File', + 'FinancialType', + 'LocBlock', + 'MailingEventConfirm', + 'MailingEventResubscribe', + 'MailingEventSubscribe', + 'MailingEventUnsubscribe', + 'MailingJob', + 'MembershipPayment', + 'Note', + 'SavedSearch', + 'UFJoin', + 'UFField', + 'PriceFieldValue', + 'Website', + 'JobLog', + 'GroupContact', + 'EntityTag', + 'PledgePayment', + 'PaymentProcessorType', + 'Relationship', + 'RelationshipType', + 'ParticipantPayment', + + // ones that are not real entities hence not extendable. + 'ActivityType', + 'Entity', + 'Cxn', + 'Constant', + 'Attachment', + 'CustomSearch', + 'CustomValue', + 'CxnApp', + 'Extension', + 'MailingContact', + 'User', + 'System', + 'Setting', + 'SystemLog', + 'ReportTemplate', + 'MailingRecipients', + 'SurveyRespondant', + 'Profile', + 'Payment', + 'Order', + 'MailingGroup', + 'Logging', + ); + if ($sequential === TRUE) { + return $entitiesWithout; + } + $entities = array(); + foreach ($entitiesWithout as $e) { + $entities[] = array($e); + } + return $entities; + } + /** * @param bool $sequential * @@ -784,27 +850,40 @@ public function testSimple_get($Entity) { * @param $entityName */ public function testCustomDataGet($entityName) { + $this->quickCleanup(array('civicrm_uf_match')); $this->createLoggedInUser();// so subsidiary activities are created + $entitiesWithNamingIssues = [ + 'MailingComponent' => 'Component', + 'SmsProvider' => 'Provider', + 'AclRole' => 'EntityRole', + 'MailingEventQueue' => 'Queue', + ]; + + $usableName = !empty($entitiesWithNamingIssues[$entityName]) ? $entitiesWithNamingIssues[$entityName] : $entityName; + $optionName = CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($usableName)); + if (!isset(CRM_Core_BAO_CustomQuery::$extendsMap[$entityName])) { $createdValue = $this->callAPISuccess('OptionValue', 'create', [ 'option_group_id' => 'cg_extend_objects', - 'label' => $entityName, - 'value' => $entityName, - 'name' => CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($entityName)), + 'label' => $usableName, + 'value' => $usableName, + 'name' => $optionName, ]); } // We are not passing 'check_permissions' so the the more limited permissions *should* be // ignored but per CRM-17700 there is a history of custom data applying permissions when it shouldn't. CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'view my contact'); - $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, $entityName . 'Test.php'); + $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, $usableName . 'Test.php'); $customFieldName = 'custom_' . $ids['custom_field_id']; $objects = $this->getMockableBAOObjects($entityName, 1); $params = array('id' => $objects[0]->id, 'custom_' . $ids['custom_field_id'] => "custom string"); $result = $this->callAPISuccess($entityName, 'create', $params); + $this->assertTrue(isset($result['id']), 'no id on ' . $entityName); $getParams = array('id' => $result['id'], 'return' => array($customFieldName)); $check = $this->callAPISuccess($entityName, 'get', $getParams); + $this->assertTrue(!empty($check['values'][$check['id']][$customFieldName]), 'Custom data not present for ' . $entityName); $this->assertEquals("custom string", $check['values'][$check['id']][$customFieldName], 'Custom data not present for ' . $entityName); $this->customFieldDelete($ids['custom_field_id']);