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