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