Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-04-21-08-12-12
[civicrm-core.git] / api / v3 / examples / Activity / ContactRefCustomField.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
9f1b81e0 3 * Test Generated example of using activity Create API
fb32de45 4 * demonstrates create with Contact Reference Custom Field *
6a488035
TO
5 */
6function activity_create_example(){
feb2a730 7$params = array(
9f1b81e0 8 'source_contact_id' => 1,
edb0d67a 9 'activity_type_id' => '46',
6a488035
TO
10 'subject' => 'test activity type id',
11 'activity_date_time' => '2011-06-02 14:36:13',
12 'status_id' => 2,
13 'priority_id' => 1,
14 'duration' => 120,
15 'location' => 'Pensulvania',
16 'details' => 'a test activity',
9f1b81e0 17 'custom_2' => '1',
6a488035
TO
18);
19
fb32de45 20try{
9f1b81e0 21 $result = civicrm_api3('activity', 'Create', $params);
fb32de45 22}
23catch (CiviCRM_API3_Exception $e) {
24 // handle error here
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
28 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
29}
6a488035 30
fb32de45 31return $result;
6a488035
TO
32}
33
fb32de45 34/**
6a488035
TO
35 * Function returns array of result expected from previous function
36 */
37function activity_create_expectedresult(){
38
feb2a730 39 $expectedResult = array(
6a488035
TO
40 'is_error' => 0,
41 'version' => 3,
42 'count' => 1,
43 'id' => 1,
feb2a730 44 'values' => array(
45 '1' => array(
6a488035 46 'id' => '1',
6a488035 47 'source_record_id' => '',
edb0d67a 48 'activity_type_id' => '46',
6a488035
TO
49 'subject' => 'test activity type id',
50 'activity_date_time' => '20110602143613',
51 'duration' => '120',
52 'location' => 'Pensulvania',
53 'phone_id' => '',
54 'phone_number' => '',
55 'details' => 'a test activity',
56 'status_id' => '2',
57 'priority_id' => '1',
58 'parent_id' => '',
59 'is_test' => '',
60 'medium_id' => '',
61 'is_auto' => '',
62 'relationship_id' => '',
63 'is_current_revision' => '',
64 'original_id' => '',
65 'result' => '',
66 'is_deleted' => '',
67 'campaign_id' => '',
68 'engagement_level' => '',
69 'weight' => '',
70 ),
71 ),
72);
73
fb32de45 74 return $expectedResult;
6a488035
TO
75}
76
77
78/*
79* This example has been generated from the API test suite. The test that created it is called
80*
81* testActivityCreateCustomContactRefField and can be found in
69d79249 82* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
6a488035
TO
83*
84* You can see the outcome of the API tests at
69d79249 85* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
86*
87* To Learn about the API read
69d79249 88* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 89*
69d79249
E
90* Browse the api on your own site with the api explorer
91* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
92*
93* Read more about testing here
94* http://wiki.civicrm.org/confluence/display/CRM/Testing
95*
96* API Standards documentation:
97* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 98*/