4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.4 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
30 * Include class definitions
32 require_once 'tests/phpunit/CiviTest/CiviUnitTestCase.php';
35 * Test APIv3 civicrm_profile_* functions
39 class api_v3_ProfileTest
extends CiviUnitTestCase
{
40 protected $_apiversion;
41 protected $_profileID = 0;
42 protected $_membershipTypeID;
43 protected $_contactID;
46 'name' => 'Profile Test',
47 'description' => 'Test all profile API methods.',
48 'group' => 'CiviCRM API Tests',
53 $this->_apiversion
= 3;
55 $config = CRM_Core_Config
::singleton();
56 $config->countryLimit
[1] = 1013;
57 $config->stateLimit
[1] = 1013;
58 $this->createLoggedInUser();
59 $this->_membershipTypeID
= $this->membershipTypeCreate();
64 $this->quickCleanup(array(
69 'civicrm_contribution',
71 $this->callAPISuccess('membership_type', 'delete', array('id' => $this->_membershipTypeID
));
72 // ok can't be bothered wring an api to do this & truncating is crazy
73 CRM_Core_DAO
::executeQuery(" DELETE FROM civicrm_uf_group WHERE id IN ($this->_profileID, 26)");
76 ////////////// test $this->callAPISuccess3_profile_get //////////////////
79 * check Without ProfileId
81 function testProfileGetWithoutProfileId() {
85 $result = $this->callAPIFailure('profile', 'get', $params,
86 'Mandatory key(s) missing from params array: profile_id'
91 * check with no invalid profile Id
93 function testProfileGetInvalidProfileId() {
98 $result = $this->callAPIFailure('profile', 'get', $params);
104 function testProfileGet() {
105 $pofileFieldValues = $this->_createIndividualContact();
106 $expected = current($pofileFieldValues);
107 $contactId = key($pofileFieldValues);
109 'profile_id' => $this->_profileID
,
110 'contact_id' => $contactId,
112 $result = $this->callAPISuccess('profile', 'get', $params);
113 foreach ($expected as $profileField => $value) {
114 $this->assertEquals($value, CRM_Utils_Array
::value($profileField, $result['values']));
118 function testProfileGetMultiple() {
119 $pofileFieldValues = $this->_createIndividualContact();
120 $expected = current($pofileFieldValues);
121 $contactId = key($pofileFieldValues);
123 'profile_id' => array($this->_profileID
, 1, 'Billing'),
124 'contact_id' => $contactId,
127 $result = $this->callAPIAndDocument('profile', 'get', $params, __FUNCTION__
, __FILE__
);
128 foreach ($expected as $profileField => $value) {
129 $this->assertEquals($value, CRM_Utils_Array
::value($profileField, $result['values'][$this->_profileID
]), " error message: " . "missing/mismatching value for {$profileField}");
131 $this->assertEquals('abc1', $result['values'][1]['first_name'], " error message: " . "missing/mismatching value for {$profileField}");
132 $this->assertFalse(array_key_exists('email-Primary', $result['values'][1]), 'profile 1 doesn not include email');
133 $this->assertEquals($result['values']['Billing'], array(
134 'billing_first_name' => 'abc1',
135 'billing_middle_name' => 'J.',
136 'billing_last_name' => 'xyz1',
137 'billing_street_address-5' => '5 Saint Helier St',
138 'billing_city-5' => 'Gotham City',
139 'billing_state_province_id-5' => '1021',
140 'billing_country_id-5' => '1228',
141 'billing-email-5' => 'abc1.xyz1@yahoo.com',
142 'billing_postal_code-5' => '90210',
143 'billing-email-5' => 'abc1.xyz1@yahoo.com',
144 'email-5' => 'abc1.xyz1@yahoo.com',
148 function testProfileGetBillingUseIsBillingLocation() {
149 $individual = $this->_createIndividualContact();
150 $contactId = key($individual);
151 $this->callAPISuccess('address', 'create', array(
153 'street_address' => 'is billing st',
154 'location_type_id' => 2,
155 'contact_id' => $contactId,
158 $expected = current($individual);
161 'profile_id' => array($this->_profileID
, 1, 'Billing'),
162 'contact_id' => $contactId,
165 $result = $this->callAPISuccess('profile', 'get', $params);
166 $this->assertEquals('abc1', $result['values'][1]['first_name']);
167 $this->assertEquals(array(
168 'billing_first_name' => 'abc1',
169 'billing_middle_name' => 'J.',
170 'billing_last_name' => 'xyz1',
171 'billing_street_address-5' => 'is billing st',
172 'billing_city-5' => '',
173 'billing_state_province_id-5' => '',
174 'billing_country_id-5' => '',
175 'billing-email-5' => 'abc1.xyz1@yahoo.com',
176 'email-5' => 'abc1.xyz1@yahoo.com',
177 'billing_postal_code-5' => '',
178 ), $result['values']['Billing']);
181 function testProfileGetMultipleHasBillingLocation() {
182 $individual = $this->_createIndividualContact();
183 $contactId = key($individual);
184 $this->callAPISuccess('address', 'create', array('contact_id' => $contactId , 'street_address' => '25 Big Street', 'city' => 'big city', 'location_type_id' => 5));
185 $this->callAPISuccess('email', 'create', array('contact_id' => $contactId , 'email' => 'big@once.com', 'location_type_id' => 2, 'is_billing' => 1));
187 $expected = current($individual);
190 'profile_id' => array($this->_profileID
, 1, 'Billing'),
191 'contact_id' => $contactId,
194 $result = $this->callAPISuccess('profile', 'get', $params, __FUNCTION__
, __FILE__
);
195 $this->assertEquals('abc1', $result['values'][1]['first_name']);
196 $this->assertEquals($result['values']['Billing'], array(
197 'billing_first_name' => 'abc1',
198 'billing_middle_name' => 'J.',
199 'billing_last_name' => 'xyz1',
200 'billing_street_address-5' => '25 Big Street',
201 'billing_city-5' => 'big city',
202 'billing_state_province_id-5' => '',
203 'billing_country_id-5' => '',
204 'billing-email-5' => 'big@once.com',
205 'email-5' => 'big@once.com',
206 'billing_postal_code-5' => '',
211 * get Billing empty contact - this will return generic defaults
213 function testProfileGetBillingEmptyContact() {
216 'profile_id' => array('Billing'),
219 $result = $this->callAPISuccess('profile', 'get', $params);
220 $this->assertEquals(array(
221 'billing_first_name' => '',
222 'billing_middle_name' => '',
223 'billing_last_name' => '',
224 'billing_street_address-5' => '',
225 'billing_city-5' => '',
226 'billing_state_province_id-5' => '',
227 'billing_country_id-5' => '1228',
228 'billing_email-5' => '',
230 'billing_postal_code-5' => '',
231 ), $result['values']['Billing']);
235 * check contact activity profile without activity id
237 function testContactActivityGetWithoutActivityId() {
238 list($params, $expected) = $this->_createContactWithActivity();
240 unset($params['activity_id']);
241 $result = $this->callAPIFailure('profile', 'get', $params,
242 'Mandatory key(s) missing from params array: activity_id');
246 * check contact activity profile wrong activity id
248 function testContactActivityGetWrongActivityId() {
249 list($params, $expected) = $this->_createContactWithActivity();
251 $params['activity_id'] = 100001;
252 $result = $this->callAPIFailure('profile', 'get', $params,
253 'Invalid Activity Id (aid).');
257 * check contact activity profile with wrong activity type
259 function testContactActivityGetWrongActivityType() {
260 //flush cache by calling with reset
261 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
263 $sourceContactId = $this->householdCreate();
265 $activityparams = array(
266 'source_contact_id' => $sourceContactId,
267 'activity_type_id' => '2',
268 'subject' => 'Test activity',
269 'activity_date_time' => '20110316',
271 'location' => 'Pensulvania',
272 'details' => 'a test activity',
274 'priority_id' => '1',
277 $activity = $this->callAPISuccess('activity', 'create', $activityparams);
279 $activityValues = array_pop($activity['values']);
281 list($params, $expected) = $this->_createContactWithActivity();
283 $params['activity_id'] = $activityValues['id'];
284 $result = $this->callAPIFailure('profile', 'get', $params,
285 'This activity cannot be edited or viewed via this profile.'
290 * check contact activity profile with success
292 function testContactActivityGetSuccess() {
293 list($params, $expected) = $this->_createContactWithActivity();
295 $result = $this->callAPISuccess('profile', 'get', $params);
297 foreach ($expected as $profileField => $value) {
298 $this->assertEquals($value, CRM_Utils_Array
::value($profileField, $result['values']), "In line " . __LINE__
. " error message: " . "missing/mismatching value for {$profileField}"
304 * Check getfields works & gives us our fields
306 function testGetFields() {
307 $this->_createIndividualProfile();
308 $this->_addCustomFieldToProfile($this->_profileID
);
309 $result = $this->callAPIAndDocument('profile', 'getfields', array('action' => 'submit', 'profile_id' => $this->_profileID
), __FUNCTION__
, __FILE__
,
310 'demonstrates retrieving profile fields passing in an id');
311 $this->assertArrayKeyExists('first_name', $result['values']);
312 $this->assertEquals('2', $result['values']['first_name']['type']);
313 $this->assertEquals('Email', $result['values']['email-primary']['title']);
314 $this->assertEquals('civicrm_state_province', $result['values']['state_province-1']['pseudoconstant']['table']);
315 $this->assertEquals('defaultValue', $result['values']['custom_1']['default_value']);
316 $this->assertFalse(array_key_exists('participant_status', $result['values']));
319 * Check getfields works & gives us our fields - partipant profile
321 function testGetFieldsParticipantProfile() {
322 $result = $this->callAPISuccess('profile', 'getfields', array(
323 'action' => 'submit',
324 'profile_id' => 'participant_status',
325 'get_options' => 'all')
327 $this->assertTrue(array_key_exists('participant_status', $result['values']));
328 $this->assertEquals('Attended', $result['values']['participant_status']['options'][2]);
332 * Check getfields works & gives us our fields - membership_batch_entry
333 * (getting to the end with no e-notices is pretty good evidence it's working)
335 function testGetFieldsMembershipBatchProfile() {
336 $result = $this->callAPISuccess('profile', 'getfields', array(
337 'action' => 'submit',
338 'profile_id' => 'membership_batch_entry',
339 'get_options' => 'all')
341 $this->assertTrue(array_key_exists('total_amount', $result['values']));
342 $this->assertEquals(12, $result['values']['receive_date']['type']);
346 * Check getfields works & gives us our fields - do them all
347 * (getting to the end with no e-notices is pretty good evidence it's working)
349 function testGetFieldsAllProfiles() {
350 $result = $this->callAPISuccess('uf_group', 'get', array('return' => 'id'));
351 $profileIDs = array_keys($result['values']);
352 foreach ($profileIDs as $profileID) {
353 $result = $this->callAPISuccess('profile', 'getfields', array(
354 'action' => 'submit',
355 'profile_id' => $profileID,
356 'get_options' => 'all')
360 /////////////// test $this->callAPISuccess3_profile_set //////////////////
363 * check Without ProfileId
365 function testProfileSubmitWithoutProfileId() {
369 $result = $this->callAPIFailure('profile', 'submit', $params,
370 'Mandatory key(s) missing from params array: profile_id'
375 * check with no invalid profile Id
377 function testProfileSubmitInvalidProfileId() {
380 'profile_id' => 1000,
382 $result = $this->callAPIFailure('profile', 'submit', $params);
386 * check with missing required field in profile
388 function testProfileSubmitCheckProfileRequired() {
389 $pofileFieldValues = $this->_createIndividualContact();
390 current($pofileFieldValues);
391 $contactId = key($pofileFieldValues);
392 $updateParams = array(
393 'first_name' => 'abc2',
394 'last_name' => 'xyz2',
395 'phone-1-1' => '022 321 826',
396 'country-1' => '1013',
397 'state_province-1' => '1000',
400 $params = array_merge(array('profile_id' => $this->_profileID
, 'contact_id' => $contactId),
404 $result = $this->callAPIFailure('profile', 'submit', $params,
405 "Missing required parameters for profile id $this->_profileID: email-Primary"
412 function testProfileSubmit() {
413 $pofileFieldValues = $this->_createIndividualContact();
414 current($pofileFieldValues);
415 $contactId = key($pofileFieldValues);
417 $updateParams = array(
418 'first_name' => 'abc2',
419 'last_name' => 'xyz2',
420 'email-primary' => 'abc2.xyz2@gmail.com',
421 'phone-1-1' => '022 321 826',
422 'country-1' => '1013',
423 'state_province-1' => '1000',
426 $params = array_merge(array(
427 'profile_id' => $this->_profileID
,
428 'contact_id' => $contactId,
431 $result = $this->callAPIAndDocument('profile', 'submit', $params, __FUNCTION__
, __FILE__
);
434 'profile_id' => $this->_profileID
,
435 'contact_id' => $contactId,
437 $profileDetails = $this->callAPISuccess('profile', 'get', $getParams);
439 foreach ($updateParams as $profileField => $value) {
440 $this->assertEquals($value, CRM_Utils_Array
::value($profileField, $profileDetails['values']), "missing/mismatching value for {$profileField}"
443 unset($params['email-primary']);
444 $params['email-Primary'] = 'my@mail.com';
445 $this->callAPISuccess('profile', 'submit', $params);
446 $profileDetails = $this->callAPISuccess('profile', 'get', $getParams);
447 $this->assertEquals('my@mail.com', $profileDetails['values']['email-Primary']);
451 * set is deprecated but we need to ensure it still works
453 function testLegacySet() {
454 $pofileFieldValues = $this->_createIndividualContact();
455 current($pofileFieldValues);
456 $contactId = key($pofileFieldValues);
458 $updateParams = array(
459 'first_name' => 'abc2',
460 'last_name' => 'xyz2',
461 'email-Primary' => 'abc2.xyz2@gmail.com',
462 'phone-1-1' => '022 321 826',
463 'country-1' => '1013',
464 'state_province-1' => '1000',
467 $params = array_merge(array(
468 'profile_id' => $this->_profileID
,
469 'contact_id' => $contactId,
472 $result = $this->callAPISuccess('profile', 'set', $params);
473 $this->assertArrayKeyExists('values', $result);
475 'profile_id' => $this->_profileID
,
476 'contact_id' => $contactId,
478 $profileDetails = $this->callAPISuccess('profile', 'get', $getParams);
480 foreach ($updateParams as $profileField => $value) {
481 $this->assertEquals($value, CRM_Utils_Array
::value($profileField, $profileDetails['values']), "In line " . __LINE__
. " error message: " . "missing/mismatching value for {$profileField}"
486 * check contact activity profile without activity id
488 function testContactActivitySubmitWithoutActivityId() {
489 list($params, $expected) = $this->_createContactWithActivity();
491 $params = array_merge($params, $expected);
492 unset($params['activity_id']);
493 $result = $this->callAPIFailure('profile', 'submit', $params);
494 $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: activity_id');
498 * check contact activity profile wrong activity id
500 function testContactActivitySubmitWrongActivityId() {
501 list($params, $expected) = $this->_createContactWithActivity();
502 $params = array_merge($params, $expected);
503 $params['activity_id'] = 100001;
504 $result = $this->callAPIFailure('profile', 'submit', $params);
505 $this->assertEquals($result['error_message'], 'Invalid Activity Id (aid).');
509 * check contact activity profile with wrong activity type
511 function testContactActivitySubmitWrongActivityType() {
512 //flush cache by calling with reset
513 $activityTypes = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
515 $sourceContactId = $this->householdCreate();
517 $activityparams = array(
518 'source_contact_id' => $sourceContactId,
519 'activity_type_id' => '2',
520 'subject' => 'Test activity',
521 'activity_date_time' => '20110316',
523 'location' => 'Pensulvania',
524 'details' => 'a test activity',
526 'priority_id' => '1',
529 $activity = $this->callAPISuccess('activity', 'create', $activityparams);
531 $activityValues = array_pop($activity['values']);
533 list($params, $expected) = $this->_createContactWithActivity();
535 $params = array_merge($params, $expected);
536 $params['activity_id'] = $activityValues['id'];
537 $result = $this->callAPIFailure('profile', 'submit', $params,
538 'This activity cannot be edited or viewed via this profile.');
542 * check contact activity profile with success
544 function testContactActivitySubmitSuccess() {
545 list($params, $expected) = $this->_createContactWithActivity();
547 $updateParams = array(
548 'first_name' => 'abc2',
549 'last_name' => 'xyz2',
550 'email-Primary' => 'abc2.xyz2@yahoo.com',
551 'activity_subject' => 'Test Meeting',
552 'activity_details' => 'a test activity details',
553 'activity_duration' => '100',
554 'activity_date_time' => '03/08/2010',
555 'activity_status_id' => '2',
557 $profileParams = array_merge($params, $updateParams);
558 $this->callAPISuccess('profile', 'submit', $profileParams);
559 $result = $this->callAPISuccess('profile', 'get', $params);
561 foreach ($updateParams as $profileField => $value) {
562 $this->assertEquals($value, CRM_Utils_Array
::value($profileField, $result['values']), "In line " . __LINE__
. " error message: " . "missing/mismatching value for {$profileField}"
568 * check profile apply Without ProfileId
570 function testProfileApplyWithoutProfileId() {
574 $result = $this->callAPIFailure('profile', 'apply', $params,
575 'Mandatory key(s) missing from params array: profile_id');
579 * check profile apply with no invalid profile Id
581 function testProfileApplyInvalidProfileId() {
584 'profile_id' => 1000,
586 $result = $this->callAPIFailure('profile', 'apply', $params);
592 function testProfileApply() {
593 $pofileFieldValues = $this->_createIndividualContact();
594 current($pofileFieldValues);
595 $contactId = key($pofileFieldValues);
598 'profile_id' => $this->_profileID
,
599 'contact_id' => $contactId,
600 'first_name' => 'abc2',
601 'last_name' => 'xyz2',
602 'email-Primary' => 'abc2.xyz2@gmail.com',
603 'phone-1-1' => '022 321 826',
604 'country-1' => '1013',
605 'state_province-1' => '1000',
608 $result = $this->callAPIAndDocument('profile', 'apply', $params, __FUNCTION__
, __FILE__
);
610 // Expected field values
611 $expected['contact'] = array(
612 'contact_id' => $contactId,
613 'contact_type' => 'Individual',
614 'first_name' => 'abc2',
615 'last_name' => 'xyz2',
617 $expected['email'] = array(
618 'location_type_id' => 1,
620 'email' => 'abc2.xyz2@gmail.com',
623 $expected['phone'] = array(
624 'location_type_id' => 1,
626 'phone_type_id' => 1,
627 'phone' => '022 321 826',
629 $expected['address'] = array(
630 'location_type_id' => 1,
632 'country_id' => 1013,
633 'state_province_id' => 1000,
636 foreach ($expected['contact'] as $field => $value) {
637 $this->assertEquals($value, CRM_Utils_Array
::value($field, $result['values']), "In line " . __LINE__
. " error message: " . "missing/mismatching value for {$field}"
642 'email', 'phone', 'address') as $fieldType) {
643 $typeValues = array_pop($result['values'][$fieldType]);
644 foreach ($expected[$fieldType] as $field => $value) {
645 $this->assertEquals($value, CRM_Utils_Array
::value($field, $typeValues), "In line " . __LINE__
. " error message: " . "missing/mismatching value for {$field} ({$fieldType})"
652 * Helper function to create an Individual with address/email/phone info. Import UF Group and UF Fields
654 function _createIndividualContact($params = array()) {
655 $contactParams = array_merge(array(
656 'first_name' => 'abc1',
657 'last_name' => 'xyz1',
658 'email' => 'abc1.xyz1@yahoo.com',
659 'api.address.create' => array(
660 'location_type_id' => 1,
662 'street_address' => '5 Saint Helier St',
664 'country' => 'United States',
665 'state_province' => 'Michigan',
666 'supplemental_address_1' => 'Hallmark Ct',
667 'supplemental_address_2' => 'Jersey Village',
668 'postal_code' => '90210',
669 'city' => 'Gotham City',
672 'api.phone.create' => array(
673 'location_type_id' => '1',
674 'phone' => '021 512 755',
675 'phone_type_id' => '1',
681 $this->_contactID
= $this->individualCreate($contactParams);
682 $this->_createIndividualProfile();
683 // expected result of above created profile with contact Id $contactId
684 $profileData[$this->_contactID
] = array(
685 'first_name' => 'abc1',
686 'last_name' => 'xyz1',
687 'email-primary' => 'abc1.xyz1@yahoo.com',
688 'phone-1-1' => '021 512 755',
689 'country-1' => '1228',
690 'state_province-1' => '1021',
696 function _createContactWithActivity() {
697 // @TODO: Create profile with custom fields
698 $op = new PHPUnit_Extensions_Database_Operation_Insert();
699 $op->execute($this->_dbconn
,
700 new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(
701 dirname(__FILE__
) . '/dataset/uf_group_contact_activity_26.xml'
704 // hack: xml data set do not accept \ 1 (CRM_Core_DAO::VALUE_SEPARATOR)
705 CRM_Core_DAO
::setFieldValue('CRM_Core_DAO_UFGroup', '26', 'group_type', 'Individual,Contact,Activity' . CRM_Core_DAO
::VALUE_SEPARATOR
. 'ActivityType:1');
707 $sourceContactId = $this->individualCreate();
708 $contactParams = array(
709 'first_name' => 'abc1',
710 'last_name' => 'xyz1',
711 'contact_type' => 'Individual',
712 'email' => 'abc1.xyz1@yahoo.com',
713 'api.address.create' => array(
714 'location_type_id' => 1,
716 'name' => 'Saint Helier St',
718 'country' => 'United States',
719 'state_province' => 'Michigan',
720 'supplemental_address_1' => 'Hallmark Ct',
721 'supplemental_address_2' => 'Jersey Village',
725 $contact = $this->callAPISuccess('contact', 'create', $contactParams);
727 $keys = array_keys($contact['values']);
728 $contactId = array_pop($keys);
730 $this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], "In line " . __LINE__
. " error message: " . CRM_Utils_Array
::value('error_message', $contact['values'][$contactId]['api.address.create'])
733 $activityParams = array(
734 'source_contact_id' => $sourceContactId,
735 'assignee_contact_id' => $contactId,
736 'activity_type_id' => '1',
737 'subject' => 'Make-it-Happen Meeting',
738 'activity_date_time' => '20110316',
740 'location' => 'Pensulvania',
741 'details' => 'a test activity',
743 'priority_id' => '1',
745 $activity = $this->callAPISuccess('activity', 'create', $activityParams);
747 $activityValues = array_pop($activity['values']);
749 // valid parameters for above profile
750 $profileParams = array(
752 'contact_id' => $contactId,
753 'activity_id' => $activityValues['id'],
756 // expected result of above created profile
758 'first_name' => 'abc1',
759 'last_name' => 'xyz1',
760 'email-Primary' => 'abc1.xyz1@yahoo.com',
761 'activity_subject' => 'Make-it-Happen Meeting',
762 'activity_details' => 'a test activity',
763 'activity_duration' => '120',
764 'activity_date_time_time' => '12:00AM',
765 'activity_date_time' => '03/16/2011',
766 'activity_status_id' => '1',
769 return array($profileParams, $expected);
774 function _createIndividualProfile() {
776 // creating these via the api as we want to utilise & test the flushing of caches when fields created
779 $ufGroupParams = array(
780 'group_type' => 'Individual,Contact',// really we should remove this & test the ufField create sets it
781 'name' => 'test_individual_contact_profile',
782 'title' => 'Flat Coffee',
783 'api.uf_field.create' => array(
785 'field_name' => 'first_name',
787 'visibility' => 'Public Pages and Listings',
788 'field_type' => 'Individual',
789 'label' => 'First Name',
792 'field_name' => 'last_name',
794 'visibility' => 'Public Pages and Listings',
795 'field_type' => 'Individual',
796 'label' => 'Last Name',
799 'field_name' => 'email',
801 'visibility' => 'Public Pages and Listings',
802 'field_type' => 'Contact',
806 'field_name' => 'phone',
808 'visibility' => 'Public Pages and Listings',
809 'field_type' => 'Contact',
810 'location_type_id' => 1,
811 'phone_type_id' => 1,
815 'field_name' => 'country',
817 'visibility' => 'Public Pages and Listings',
818 'field_type' => 'Contact',
819 'location_type_id' => 1,
823 'field_name' => 'state_province',
825 'visibility' => 'Public Pages and Listings',
826 'field_type' => 'Contact',
827 'location_type_id' => 1,
828 'label' => 'State Province'
831 'field_name' => 'postal_code',
833 'field_type' => 'Contact',
834 'location_type_id' => 1,
835 'label' => 'State Province'
839 $profile = $this->callAPISuccess('uf_group', 'create', $ufGroupParams);
840 $this->_profileID
= $profile['id'];
843 function _addCustomFieldToProfile($profileID) {
844 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__
, '');
845 $this->uFFieldCreate(array('uf_group_id' => $profileID, 'field_name' => 'custom_' . $ids['custom_field_id'], 'contact_type' => 'Contact'));