Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the Participant.get API. |
50fb255d | 4 | * |
5c49fee0 | 5 | * Criteria delete by nesting a GET & a DELETE. |
50fb255d | 6 | * |
7 | * @return array | |
8 | * API result array | |
9 | */ | |
10 | function participant_get_example() { | |
cf8f0fff | 11 | $params = [ |
50fb255d | 12 | 'contact_id' => 4, |
13 | 'api.participant.delete' => 1, | |
cf8f0fff | 14 | ]; |
6a488035 | 15 | |
50fb255d | 16 | try{ |
a828d7b8 | 17 | $result = civicrm_api3('Participant', 'get', $params); |
50fb255d | 18 | } |
19 | catch (CiviCRM_API3_Exception $e) { | |
20 | // Handle error here. | |
21 | $errorMessage = $e->getMessage(); | |
22 | $errorCode = $e->getErrorCode(); | |
23 | $errorData = $e->getExtraParams(); | |
cf8f0fff | 24 | return [ |
5be22f39 | 25 | 'is_error' => 1, |
26 | 'error_message' => $errorMessage, | |
50fb255d | 27 | 'error_code' => $errorCode, |
28 | 'error_data' => $errorData, | |
cf8f0fff | 29 | ]; |
50fb255d | 30 | } |
31 | ||
32 | return $result; | |
6a488035 TO |
33 | } |
34 | ||
fb32de45 | 35 | /** |
50fb255d | 36 | * Function returns array of result expected from previous function. |
37 | * | |
38 | * @return array | |
39 | * API result array | |
6a488035 | 40 | */ |
50fb255d | 41 | function participant_get_expectedresult() { |
6a488035 | 42 | |
cf8f0fff | 43 | $expectedResult = [ |
50fb255d | 44 | 'is_error' => 0, |
45 | 'version' => 3, | |
46 | 'count' => 2, | |
cf8f0fff CW |
47 | 'values' => [ |
48 | '2' => [ | |
50fb255d | 49 | 'contact_id' => '4', |
50 | 'contact_type' => 'Individual', | |
51 | 'contact_sub_type' => '', | |
52 | 'sort_name' => 'Anderson, Anthony', | |
53 | 'display_name' => 'Mr. Anthony Anderson II', | |
1d8ee3d6 | 54 | 'event_id' => '41', |
50fb255d | 55 | 'event_title' => 'Annual CiviCRM meet', |
56 | 'event_start_date' => '2013-07-29 00:00:00', | |
57 | 'event_end_date' => '2013-08-04 00:00:00', | |
58 | 'participant_id' => '2', | |
59 | 'participant_fee_level' => '', | |
60 | 'participant_fee_amount' => '', | |
61 | 'participant_fee_currency' => '', | |
62 | 'event_type' => 'Conference', | |
63 | 'participant_status_id' => '2', | |
64 | 'participant_status' => 'Attended', | |
50fb255d | 65 | 'participant_role_id' => '1', |
1d8ee3d6 | 66 | 'participant_role' => 'Attendee', |
50fb255d | 67 | 'participant_register_date' => '2007-02-19 00:00:00', |
68 | 'participant_source' => 'Wimbeldon', | |
69 | 'participant_note' => '', | |
70 | 'participant_is_pay_later' => 0, | |
71 | 'participant_is_test' => 0, | |
1d8ee3d6 | 72 | 'participant_registered_by_id' => '1', |
50fb255d | 73 | 'participant_discount_name' => '', |
74 | 'participant_campaign_id' => '', | |
75 | 'id' => '2', | |
cf8f0fff | 76 | 'api.participant.delete' => [ |
50fb255d | 77 | 'is_error' => 0, |
78 | 'version' => 3, | |
79 | 'count' => 1, | |
80 | 'values' => 1, | |
cf8f0fff CW |
81 | ], |
82 | ], | |
83 | '3' => [ | |
50fb255d | 84 | 'contact_id' => '4', |
85 | 'contact_type' => 'Individual', | |
86 | 'contact_sub_type' => '', | |
87 | 'sort_name' => 'Anderson, Anthony', | |
88 | 'display_name' => 'Mr. Anthony Anderson II', | |
1d8ee3d6 | 89 | 'event_id' => '41', |
50fb255d | 90 | 'event_title' => 'Annual CiviCRM meet', |
91 | 'event_start_date' => '2013-07-29 00:00:00', | |
92 | 'event_end_date' => '2013-08-04 00:00:00', | |
93 | 'participant_id' => '3', | |
94 | 'participant_fee_level' => '', | |
95 | 'participant_fee_amount' => '', | |
96 | 'participant_fee_currency' => '', | |
97 | 'event_type' => 'Conference', | |
98 | 'participant_status_id' => '2', | |
99 | 'participant_status' => 'Attended', | |
50fb255d | 100 | 'participant_role_id' => '1', |
1d8ee3d6 | 101 | 'participant_role' => 'Attendee', |
50fb255d | 102 | 'participant_register_date' => '2007-02-19 00:00:00', |
103 | 'participant_source' => 'Wimbeldon', | |
104 | 'participant_note' => '', | |
105 | 'participant_is_pay_later' => 0, | |
106 | 'participant_is_test' => 0, | |
107 | 'participant_registered_by_id' => '', | |
108 | 'participant_discount_name' => '', | |
109 | 'participant_campaign_id' => '', | |
110 | 'id' => '3', | |
cf8f0fff | 111 | 'api.participant.delete' => [ |
50fb255d | 112 | 'is_error' => 0, |
113 | 'version' => 3, | |
114 | 'count' => 1, | |
115 | 'values' => 1, | |
cf8f0fff CW |
116 | ], |
117 | ], | |
118 | ], | |
119 | ]; | |
6a488035 | 120 | |
fb32de45 | 121 | return $expectedResult; |
6a488035 TO |
122 | } |
123 | ||
a828d7b8 | 124 | /* |
50fb255d | 125 | * This example has been generated from the API test suite. |
a828d7b8 CW |
126 | * The test that created it is called "testNestedDelete" |
127 | * and can be found at: | |
69d79249 | 128 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php |
6a488035 TO |
129 | * |
130 | * You can see the outcome of the API tests at | |
69d79249 | 131 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
132 | * |
133 | * To Learn about the API read | |
69d79249 | 134 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 135 | * |
69d79249 | 136 | * Browse the api on your own site with the api explorer |
41d4d31f | 137 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
138 | * |
139 | * Read more about testing here | |
140 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
141 | * | |
142 | * API Standards documentation: | |
143 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 144 | */ |