+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* @return array
*/
public static function custom_data_incl_non_std_entities_get() {
- $customDataEntities = self::custom_data_entities();
- $customDataEntities[] = ['UFGroup'];
- $customDataEntities[] = ['PriceSet'];
- $customDataEntities[] = ['PaymentToken'];
- return $customDataEntities;
+ return static::entities(static::toBeSkipped_custom_data_creatable(TRUE));
}
/**
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',
+ 'JobLog',
+ 'GroupContact',
+ 'EntityTag',
+ 'PledgePayment',
+ 'PaymentProcessorType',
+ 'Relationship',
+ 'RelationshipType',
+
+ // 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
*
'MailingContact',
'EntityTag',
'Participant',
- 'ParticipantPayment',
'Setting',
'SurveyRespondant',
'MailingRecipients',
'Constant',
'Entity',
'Location',
- 'Domain',
'Profile',
'CustomValue',
'SurveyRespondant',
'OptionGroup',
'Membership',
'Group',
- 'GroupOrganization',
- 'GroupNesting',
'File',
'EntityTag',
'CustomField',
'GroupContact',
'MembershipPayment',
'Participant',
- 'ParticipantPayment',
'LineItem',
'PledgePayment',
'ContributionPage',
'definition',
),
),
+ 'Domain' => ['cant_update' => ['domain_version']],
'MembershipBlock' => array(
'cant_update' => array(
// The fake/auto-generated values leave us unable to properly cleanup fake data
* @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']);
'id' => $entity['id'],
$field => isset($entity[$field]) ? $entity[$field] : NULL,
);
+ if (!empty($specs['serialize'])) {
+ $updateParams[$field] = $entity[$field] = (array) $specs['serialize'];
+ }
if (isset($updateParams['financial_type_id']) && in_array($entityName, array('Grant'))) {
//api has special handling on these 2 fields for backward compatibility reasons
$entity['contribution_type_id'] = $updateParams['financial_type_id'];
);
$checkEntity = $this->callAPISuccess($entityName, 'getsingle', $checkParams);
+ if (!empty($specs['serialize']) && !is_array($checkEntity[$field])) {
+ // Put into serialized format for comparison if 'get' has not returned serialized.
+ $entity[$field] = CRM_Core_DAO::serializeField($checkEntity[$field], $specs['serialize']);
+ }
$this->assertAPIArrayComparison($entity, $checkEntity, array(), "checking if $fieldName was correctly updated\n" . print_r(array(
'update-params' => $updateParams,
* @throws \PHPUnit_Framework_IncompleteTestError
*/
public function testInvalidID_delete($Entity) {
- $result = $this->callAPIFailure($Entity, 'Delete', array('id' => 999));
+ $result = $this->callAPIFailure($Entity, 'Delete', array('id' => 999999));
}
/**