CRM-13234 add test to lock in profile set as working
[civicrm-core.git] / tests / phpunit / api / v3 / ProfileTest.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.4 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
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. |
14 | |
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. |
19 | |
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 +--------------------------------------------------------------------+
27 */
28
29 /**
30 * Include class definitions
31 */
32 require_once 'tests/phpunit/CiviTest/CiviUnitTestCase.php';
33
34 /**
35 * Test APIv3 civicrm_profile_* functions
36 *
37 * @package CiviCRM
38 */
39 class api_v3_ProfileTest extends CiviUnitTestCase {
40 protected $_apiversion;
41 protected $_profileID;
42 function get_info() {
43 return array(
44 'name' => 'Profile Test',
45 'description' => 'Test all profile API methods.',
46 'group' => 'CiviCRM API Tests',
47 );
48 }
49
50 function setUp() {
51 $this->_apiversion = 3;
52 parent::setUp();
53 $config = CRM_Core_Config::singleton();
54 $config->countryLimit[1] = 1013;
55 $config->stateLimit[1] = 1013;
56 }
57
58 function tearDown() {
59
60 $this->quickCleanup(array(
61 'civicrm_contact',
62 'civicrm_phone',
63 'civicrm_address',
64 ), TRUE);
65 // ok can't be bothered wring an api to do this & truncating is crazy
66 CRM_Core_DAO::executeQuery(' DELETE FROM civicrm_uf_group WHERE id IN (25, 26)');
67 }
68
69 ////////////// test $this->callAPISuccess3_profile_get //////////////////
70
71 /**
72 * check Without ProfileId
73 */
74 function testProfileGetWithoutProfileId() {
75 $params = array(
76 'contact_id' => 1,
77 );
78 $result = $this->callAPIFailure('profile', 'get', $params,
79 'Mandatory key(s) missing from params array: profile_id'
80 );
81 }
82
83 /**
84 * check with no invalid profile Id
85 */
86 function testProfileGetInvalidProfileId() {
87 $params = array(
88 'contact_id' => 1,
89 'profile_id' => 1000,
90 );
91 $result = $this->callAPIFailure('profile', 'get', $params);
92 }
93
94 /**
95 * check with success
96 */
97 function testProfileGet() {
98 $pofileFieldValues = $this->_createIndividualContact();
99 $expected = current($pofileFieldValues);
100 $contactId = key($pofileFieldValues);
101 $params = array(
102 'profile_id' => 25,
103 'contact_id' => $contactId,
104 );
105 $result = $this->callAPISuccess('profile', 'get', $params);
106 foreach ($expected as $profileField => $value) {
107 $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
108 );
109 }
110 }
111
112 function testProfileGetMultiple() {
113 $pofileFieldValues = $this->_createIndividualContact();
114 $expected = current($pofileFieldValues);
115 $contactId = key($pofileFieldValues);
116 $params = array(
117 'profile_id' => array(25, 1, 'Billing'),
118 'contact_id' => $contactId,
119 );
120
121 $result = $this->callAPIAndDocument('profile', 'get', $params, __FUNCTION__, __FILE__);
122 foreach ($expected as $profileField => $value) {
123 $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values'][25]), " error message: " . "missing/mismatching value for {$profileField}");
124 }
125 $this->assertEquals('abc1', $result['values'][1]['first_name'], " error message: " . "missing/mismatching value for {$profileField}");
126 $this->assertFalse(array_key_exists('email-Primary', $result['values'][1]), 'profile 1 doesn not include email');
127 $this->assertEquals($result['values']['Billing'], array(
128 'billing_first_name' => 'abc1',
129 'billing_middle_name' => 'J.',
130 'billing_last_name' => 'xyz1',
131 'billing_street_address-5' => '5 Saint Helier St',
132 'billing_city-5' => 'Gotham City',
133 'billing_state_province_id-5' => '1021',
134 'billing_country_id-5' => '',
135 'billing-email-5' => 'abc1.xyz1@yahoo.com',
136 'billing_postal_code-5' => '90210',
137 'billing-email-5' => 'abc1.xyz1@yahoo.com',
138 'email-5' => 'abc1.xyz1@yahoo.com',
139 ));
140 }
141
142 function testProfileGetBillingUseIsBillingLocation() {
143 $individual = $this->_createIndividualContact();
144 $contactId = key($individual);
145 $this->callAPISuccess('address', 'create', array(
146 'is_billing' => 1,
147 'street_address' => 'is billing st',
148 'location_type_id' => 2,
149 'contact_id' => $contactId,
150 ));
151
152 $expected = current($individual);
153
154 $params = array(
155 'profile_id' => array(25, 1, 'Billing'),
156 'contact_id' => $contactId,
157 );
158
159 $result = $this->callAPISuccess('profile', 'get', $params);
160 $this->assertEquals('abc1', $result['values'][1]['first_name']);
161 $this->assertEquals(array(
162 'billing_first_name' => 'abc1',
163 'billing_middle_name' => 'J.',
164 'billing_last_name' => 'xyz1',
165 'billing_street_address-5' => 'is billing st',
166 'billing_city-5' => '',
167 'billing_state_province_id-5' => '',
168 'billing_country_id-5' => '',
169 'billing-email-5' => 'abc1.xyz1@yahoo.com',
170 'email-5' => 'abc1.xyz1@yahoo.com',
171 'billing_postal_code-5' => '',
172 ), $result['values']['Billing']);
173 }
174
175 function testProfileGetMultipleHasBillingLocation() {
176 $individual = $this->_createIndividualContact();
177 $contactId = key($individual);
178 $this->callAPISuccess('address', 'create', array('contact_id' => $contactId , 'street_address' => '25 Big Street', 'city' => 'big city', 'location_type_id' => 5));
179 $this->callAPISuccess('email', 'create', array('contact_id' => $contactId , 'email' => 'big@once.com', 'location_type_id' => 2, 'is_billing' => 1));
180
181 $expected = current($individual);
182
183 $params = array(
184 'profile_id' => array(25, 1, 'Billing'),
185 'contact_id' => $contactId,
186 );
187
188 $result = $this->callAPISuccess('profile', 'get', $params, __FUNCTION__, __FILE__);
189 $this->assertEquals('abc1', $result['values'][1]['first_name']);
190 $this->assertEquals($result['values']['Billing'], array(
191 'billing_first_name' => 'abc1',
192 'billing_middle_name' => 'J.',
193 'billing_last_name' => 'xyz1',
194 'billing_street_address-5' => '25 Big Street',
195 'billing_city-5' => 'big city',
196 'billing_state_province_id-5' => '',
197 'billing_country_id-5' => '',
198 'billing-email-5' => 'big@once.com',
199 'email-5' => 'big@once.com',
200 'billing_postal_code-5' => '',
201 ));
202 }
203
204
205 /**
206 * check contact activity profile without activity id
207 */
208 function testContactActivityGetWithoutActivityId() {
209 list($params, $expected) = $this->_createContactWithActivity();
210
211 unset($params['activity_id']);
212 $result = $this->callAPIFailure('profile', 'get', $params,
213 'Mandatory key(s) missing from params array: activity_id');
214 }
215
216 /**
217 * check contact activity profile wrong activity id
218 */
219 function testContactActivityGetWrongActivityId() {
220 list($params, $expected) = $this->_createContactWithActivity();
221
222 $params['activity_id'] = 100001;
223 $result = $this->callAPIFailure('profile', 'get', $params,
224 'Invalid Activity Id (aid).');
225 }
226
227 /*
228 * check contact activity profile with wrong activity type
229 */
230 function testContactActivityGetWrongActivityType() {
231 //flush cache by calling with reset
232 $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
233
234 $sourceContactId = $this->householdCreate();
235
236 $activityparams = array(
237 'source_contact_id' => $sourceContactId,
238 'activity_type_id' => '2',
239 'subject' => 'Test activity',
240 'activity_date_time' => '20110316',
241 'duration' => '120',
242 'location' => 'Pensulvania',
243 'details' => 'a test activity',
244 'status_id' => '1',
245 'priority_id' => '1',
246 );
247
248 $activity = $this->callAPISuccess('activity', 'create', $activityparams);
249
250 $activityValues = array_pop($activity['values']);
251
252 list($params, $expected) = $this->_createContactWithActivity();
253
254 $params['activity_id'] = $activityValues['id'];
255 $result = $this->callAPIFailure('profile', 'get', $params,
256 'This activity cannot be edited or viewed via this profile.'
257 );
258 }
259
260 /*
261 * check contact activity profile with success
262 */
263 function testContactActivityGetSuccess() {
264 list($params, $expected) = $this->_createContactWithActivity();
265
266 $result = $this->callAPISuccess('profile', 'get', $params);
267
268 foreach ($expected as $profileField => $value) {
269 $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
270 );
271 }
272 }
273
274 /**
275 * Check getfields works & gives us our fields
276 */
277 function testGetFields() {
278 $this->_createIndividualProfile();
279 $this->_addCustomFieldToProfile($this->_profileID);
280 $result = $this->callAPIAndDocument('profile', 'getfields', array('action' => 'submit', 'profile_id' => 25), __FUNCTION__, __FILE__,
281 'demonstrates retrieving profile fields passing in an id');
282 $this->assertArrayKeyExists('first_name', $result['values']);
283 $this->assertEquals('2', $result['values']['first_name']['type']);
284 $this->assertEquals('Email', $result['values']['email']['title']);
285 $this->assertEquals('civicrm_state_province', $result['values']['state_province-1']['pseudoconstant']['table']);
286 $this->assertEquals('defaultValue', $result['values']['custom_1']['default_value']);
287 $this->assertFalse(array_key_exists('participant_status', $result['values']));
288 }
289 /**
290 * Check getfields works & gives us our fields
291 */
292 function testGetFieldsParticipantProfile() {
293 $result = $this->callAPISuccess('profile', 'getfields', array(
294 'action' => 'submit',
295 'profile_id' => 'participant_status',
296 'get_options' => 'all')
297 );
298 $this->assertTrue(array_key_exists('participant_status', $result['values']));
299 $this->assertEquals('Attended', $result['values']['participant_status']['options'][2]);
300 }
301 /////////////// test $this->callAPISuccess3_profile_set //////////////////
302
303 /**
304 * check Without ProfileId
305 */
306 function testProfileSubmitWithoutProfileId() {
307 $params = array(
308 'contact_id' => 1,
309 );
310 $result = $this->callAPIFailure('profile', 'submit', $params,
311 'Mandatory key(s) missing from params array: profile_id'
312 );
313 }
314
315 /**
316 * check with no invalid profile Id
317 */
318 function testProfileSubmitInvalidProfileId() {
319 $params = array(
320 'contact_id' => 1,
321 'profile_id' => 1000,
322 );
323 $result = $this->callAPIFailure('profile', 'submit', $params);
324 }
325
326 /**
327 * check with missing required field in profile
328 */
329 function testProfileSubmitCheckProfileRequired() {
330 $pofileFieldValues = $this->_createIndividualContact();
331 current($pofileFieldValues);
332 $contactId = key($pofileFieldValues);
333 $updateParams = array(
334 'first_name' => 'abc2',
335 'last_name' => 'xyz2',
336 'phone-1-1' => '022 321 826',
337 'country-1' => '1013',
338 'state_province-1' => '1000',
339 );
340
341 $params = array_merge(array('profile_id' => 25, 'contact_id' => $contactId),
342 $updateParams
343 );
344
345 $result = $this->callAPIFailure('profile', 'submit', $params,
346 'Missing required parameters for profile id 25: email-Primary'
347 );
348 }
349
350 /**
351 * check with success
352 */
353 function testProfileSubmit() {
354 $pofileFieldValues = $this->_createIndividualContact();
355 current($pofileFieldValues);
356 $contactId = key($pofileFieldValues);
357
358 $updateParams = array(
359 'first_name' => 'abc2',
360 'last_name' => 'xyz2',
361 'email-Primary' => 'abc2.xyz2@gmail.com',
362 'phone-1-1' => '022 321 826',
363 'country-1' => '1013',
364 'state_province-1' => '1000',
365 );
366
367 $params = array_merge(array(
368 'profile_id' => 25,
369 'contact_id' => $contactId,
370 ), $updateParams);
371
372 $result = $this->callAPIAndDocument('profile', 'submit', $params, __FUNCTION__, __FILE__);
373
374 $getParams = array(
375 'profile_id' => 25,
376 'contact_id' => $contactId,
377 );
378 $profileDetails = $this->callAPISuccess('profile', 'get', $getParams);
379
380 foreach ($updateParams as $profileField => $value) {
381 $this->assertEquals($value, CRM_Utils_Array::value($profileField, $profileDetails['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
382 );
383 }
384 }
385
386 /**
387 * set is deprecated but we need to ensure it still works
388 */
389 function testLegacySet() {
390 $pofileFieldValues = $this->_createIndividualContact();
391 current($pofileFieldValues);
392 $contactId = key($pofileFieldValues);
393
394 $updateParams = array(
395 'first_name' => 'abc2',
396 'last_name' => 'xyz2',
397 'email-Primary' => 'abc2.xyz2@gmail.com',
398 'phone-1-1' => '022 321 826',
399 'country-1' => '1013',
400 'state_province-1' => '1000',
401 );
402
403 $params = array_merge(array(
404 'profile_id' => 25,
405 'contact_id' => $contactId,
406 ), $updateParams);
407
408 $result = $this->callAPISuccess('profile', 'set', $params);
409 $this->assertArrayKeyExists('values', $result);
410 $getParams = array(
411 'profile_id' => 25,
412 'contact_id' => $contactId,
413 );
414 $profileDetails = $this->callAPISuccess('profile', 'get', $getParams);
415
416 foreach ($updateParams as $profileField => $value) {
417 $this->assertEquals($value, CRM_Utils_Array::value($profileField, $profileDetails['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
418 );
419 }
420 }
421 /*
422 * check contact activity profile without activity id
423 */
424 function testContactActivitySubmitWithoutActivityId() {
425 list($params, $expected) = $this->_createContactWithActivity();
426
427 $params = array_merge($params, $expected);
428 unset($params['activity_id']);
429 $result = $this->callAPIFailure('profile', 'submit', $params);
430 $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: activity_id');
431 }
432
433 /*
434 * check contact activity profile wrong activity id
435 */
436 function testContactActivitySubmitWrongActivityId() {
437 list($params, $expected) = $this->_createContactWithActivity();
438 $params = array_merge($params, $expected);
439 $params['activity_id'] = 100001;
440 $result = $this->callAPIFailure('profile', 'submit', $params);
441 $this->assertEquals($result['error_message'], 'Invalid Activity Id (aid).');
442 }
443
444 /*
445 * check contact activity profile with wrong activity type
446 */
447 function testContactActivitySubmitWrongActivityType() {
448 //flush cache by calling with reset
449 $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
450
451 $sourceContactId = $this->householdCreate();
452
453 $activityparams = array(
454 'source_contact_id' => $sourceContactId,
455 'activity_type_id' => '2',
456 'subject' => 'Test activity',
457 'activity_date_time' => '20110316',
458 'duration' => '120',
459 'location' => 'Pensulvania',
460 'details' => 'a test activity',
461 'status_id' => '1',
462 'priority_id' => '1',
463 );
464
465 $activity = $this->callAPISuccess('activity', 'create', $activityparams);
466
467 $activityValues = array_pop($activity['values']);
468
469 list($params, $expected) = $this->_createContactWithActivity();
470
471 $params = array_merge($params, $expected);
472 $params['activity_id'] = $activityValues['id'];
473 $result = $this->callAPIFailure('profile', 'submit', $params,
474 'This activity cannot be edited or viewed via this profile.');
475 }
476
477 /*
478 * check contact activity profile with success
479 */
480 function testContactActivitySubmitSuccess() {
481 list($params, $expected) = $this->_createContactWithActivity();
482
483 $updateParams = array(
484 'first_name' => 'abc2',
485 'last_name' => 'xyz2',
486 'email-Primary' => 'abc2.xyz2@yahoo.com',
487 'activity_subject' => 'Test Meeting',
488 'activity_details' => 'a test activity details',
489 'activity_duration' => '100',
490 'activity_date_time' => '03/08/2010',
491 'activity_status_id' => '2',
492 );
493 $profileParams = array_merge($params, $updateParams);
494 $profile = $this->callAPISuccess('profile', 'submit', $profileParams);
495 $result = $this->callAPISuccess('profile', 'get', $params);
496
497 foreach ($updateParams as $profileField => $value) {
498 $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
499 );
500 }
501 }
502
503 /**
504 * check profile apply Without ProfileId
505 */
506 function testProfileApplyWithoutProfileId() {
507 $params = array(
508 'contact_id' => 1,
509 );
510 $result = $this->callAPIFailure('profile', 'apply', $params,
511 'Mandatory key(s) missing from params array: profile_id');
512 }
513
514 /**
515 * check profile apply with no invalid profile Id
516 */
517 function testProfileApplyInvalidProfileId() {
518 $params = array(
519 'contact_id' => 1,
520 'profile_id' => 1000,
521 );
522 $result = $this->callAPIFailure('profile', 'apply', $params);
523 }
524
525 /**
526 * check with success
527 */
528 function testProfileApply() {
529 $pofileFieldValues = $this->_createIndividualContact();
530 current($pofileFieldValues);
531 $contactId = key($pofileFieldValues);
532
533 $params = array(
534 'profile_id' => 25,
535 'contact_id' => $contactId,
536 'first_name' => 'abc2',
537 'last_name' => 'xyz2',
538 'email-Primary' => 'abc2.xyz2@gmail.com',
539 'phone-1-1' => '022 321 826',
540 'country-1' => '1013',
541 'state_province-1' => '1000',
542 );
543
544 $result = $this->callAPIAndDocument('profile', 'apply', $params, __FUNCTION__, __FILE__);
545
546 // Expected field values
547 $expected['contact'] = array(
548 'contact_id' => $contactId,
549 'contact_type' => 'Individual',
550 'first_name' => 'abc2',
551 'last_name' => 'xyz2',
552 );
553 $expected['email'] = array(
554 'location_type_id' => 1,
555 'is_primary' => 1,
556 'email' => 'abc2.xyz2@gmail.com',
557 );
558
559 $expected['phone'] = array(
560 'location_type_id' => 1,
561 'is_primary' => 1,
562 'phone_type_id' => 1,
563 'phone' => '022 321 826',
564 );
565 $expected['address'] = array(
566 'location_type_id' => 1,
567 'is_primary' => 1,
568 'country_id' => 1013,
569 'state_province_id' => 1000,
570 );
571
572 foreach ($expected['contact'] as $field => $value) {
573 $this->assertEquals($value, CRM_Utils_Array::value($field, $result['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$field}"
574 );
575 }
576
577 foreach (array(
578 'email', 'phone', 'address') as $fieldType) {
579 $typeValues = array_pop($result['values'][$fieldType]);
580 foreach ($expected[$fieldType] as $field => $value) {
581 $this->assertEquals($value, CRM_Utils_Array::value($field, $typeValues), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$field} ({$fieldType})"
582 );
583 }
584 }
585 }
586
587 /*
588 * Helper function to create an Individual with address/email/phone info. Import UF Group and UF Fields
589 */
590 function _createIndividualContact($params = array()) {
591 $contactParams = array_merge(array(
592 'first_name' => 'abc1',
593 'last_name' => 'xyz1',
594 'email' => 'abc1.xyz1@yahoo.com',
595 'api.address.create' => array(
596 'location_type_id' => 1,
597 'is_primary' => 1,
598 'street_address' => '5 Saint Helier St',
599 'county' => 'Marin',
600 'country' => 'United States',
601 'state_province' => 'Michigan',
602 'supplemental_address_1' => 'Hallmark Ct',
603 'supplemental_address_2' => 'Jersey Village',
604 'postal_code' => '90210',
605 'city' => 'Gotham City',
606 'is_billing' => 0,
607 ),
608 'api.phone.create' => array(
609 'location_type_id' => '1',
610 'phone' => '021 512 755',
611 'phone_type_id' => '1',
612 'is_primary' => '1',
613 ),
614 ), $params
615 );
616
617 $contactID = $this->individualCreate($contactParams);
618 $this->_createIndividualProfile();
619 // expected result of above created profile with contact Id $contactId
620 $profileData[$contactID] = array(
621 'first_name' => 'abc1',
622 'last_name' => 'xyz1',
623 'email-Primary' => 'abc1.xyz1@yahoo.com',
624 'phone-1-1' => '021 512 755',
625 'country-1' => '1228',
626 'state_province-1' => '1021',
627 );
628
629 return $profileData;
630 }
631
632 function _createContactWithActivity() {
633 // @TODO: Create profile with custom fields
634 $op = new PHPUnit_Extensions_Database_Operation_Insert();
635 $op->execute($this->_dbconn,
636 new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(
637 dirname(__FILE__) . '/dataset/uf_group_contact_activity_26.xml'
638 )
639 );
640 // hack: xml data set do not accept \ 1 (CRM_Core_DAO::VALUE_SEPARATOR)
641 CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', '26', 'group_type', 'Individual,Contact,Activity' . CRM_Core_DAO::VALUE_SEPARATOR . 'ActivityType:1');
642
643 $sourceContactId = $this->individualCreate();
644 $contactParams = array(
645 'first_name' => 'abc1',
646 'last_name' => 'xyz1',
647 'contact_type' => 'Individual',
648 'email' => 'abc1.xyz1@yahoo.com',
649 'api.address.create' => array(
650 'location_type_id' => 1,
651 'is_primary' => 1,
652 'name' => 'Saint Helier St',
653 'county' => 'Marin',
654 'country' => 'United States',
655 'state_province' => 'Michigan',
656 'supplemental_address_1' => 'Hallmark Ct',
657 'supplemental_address_2' => 'Jersey Village',
658 ),
659 );
660
661 $contact = $this->callAPISuccess('contact', 'create', $contactParams);
662
663 $keys = array_keys($contact['values']);
664 $contactId = array_pop($keys);
665
666 $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'])
667 );
668
669 $activityParams = array(
670 'source_contact_id' => $sourceContactId,
671 'assignee_contact_id' => $contactId,
672 'activity_type_id' => '1',
673 'subject' => 'Make-it-Happen Meeting',
674 'activity_date_time' => '20110316',
675 'duration' => '120',
676 'location' => 'Pensulvania',
677 'details' => 'a test activity',
678 'status_id' => '1',
679 'priority_id' => '1',
680 );
681 $activity = $this->callAPISuccess('activity', 'create', $activityParams);
682
683 $activityValues = array_pop($activity['values']);
684
685 // valid parameters for above profile
686 $profileParams = array(
687 'profile_id' => 26,
688 'contact_id' => $contactId,
689 'activity_id' => $activityValues['id'],
690 );
691
692 // expected result of above created profile
693 $expected = array(
694 'first_name' => 'abc1',
695 'last_name' => 'xyz1',
696 'email-Primary' => 'abc1.xyz1@yahoo.com',
697 'activity_subject' => 'Make-it-Happen Meeting',
698 'activity_details' => 'a test activity',
699 'activity_duration' => '120',
700 'activity_date_time_time' => '12:00AM',
701 'activity_date_time' => '03/16/2011',
702 'activity_status_id' => '1',
703 );
704
705 return array($profileParams, $expected);
706 }
707 /**
708 * Create a profile
709 */
710 function _createIndividualProfile() {
711 // Create new profile having group_type: Contact,Individual
712 $op = new PHPUnit_Extensions_Database_Operation_Insert();
713 $op->execute($this->_dbconn,
714 new PHPUnit_Extensions_Database_DataSet_XMLDataSet(
715 dirname(__FILE__) . "/dataset/uf_group_25.xml"
716 )
717 );
718 // Create Contact + Idividual fields for profile
719 $op = new PHPUnit_Extensions_Database_Operation_Insert();
720 $op->execute($this->_dbconn,
721 new PHPUnit_Extensions_Database_DataSet_XMLDataSet(
722 dirname(__FILE__) . "/dataset/uf_field_uf_group_25.xml"
723 )
724 );
725 $this->_profileID = 25;
726 }
727
728 function _addCustomFieldToProfile($profileID) {
729 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, '');
730 $this->uFFieldCreate(array('uf_group_id' => $profileID, 'field_name' => 'custom_' . $ids['custom_field_id'], 'contact_type' => 'Contact'));
731 }
732 }
733