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