Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using participant create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function participant_create_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 TO |
8 | 'contact_id' => 4, |
9 | 'event_id' => 1, | |
10 | 'status_id' => 1, | |
11 | 'role_id' => 1, | |
12 | 'register_date' => '2007-07-21 00:00:00', | |
13 | 'source' => 'Online Event Registration: API Testing', | |
6a488035 TO |
14 | 'custom_1' => 'custom string', |
15 | ); | |
16 | ||
fb32de45 | 17 | try{ |
18 | $result = civicrm_api3('participant', 'create', $params); | |
19 | } | |
20 | catch (CiviCRM_API3_Exception $e) { | |
21 | // handle error here | |
22 | $errorMessage = $e->getMessage(); | |
23 | $errorCode = $e->getErrorCode(); | |
24 | $errorData = $e->getExtraParams(); | |
25 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
26 | } | |
6a488035 | 27 | |
fb32de45 | 28 | return $result; |
6a488035 TO |
29 | } |
30 | ||
fb32de45 | 31 | /** |
6a488035 TO |
32 | * Function returns array of result expected from previous function |
33 | */ | |
34 | function participant_create_expectedresult(){ | |
35 | ||
53ca8fd7 | 36 | $expectedResult = array( |
6a488035 TO |
37 | 'is_error' => 0, |
38 | 'version' => 3, | |
39 | 'count' => 1, | |
40 | 'id' => 4, | |
53ca8fd7 | 41 | 'values' => array( |
42 | '4' => array( | |
6a488035 TO |
43 | 'id' => '4', |
44 | 'contact_id' => '4', | |
45 | 'event_id' => '1', | |
46 | 'status_id' => '1', | |
47 | 'role_id' => '1', | |
48 | 'register_date' => '20070721000000', | |
49 | 'source' => 'Online Event Registration: API Testing', | |
50 | 'fee_level' => '', | |
51 | 'is_test' => '', | |
52 | 'is_pay_later' => '', | |
53 | 'fee_amount' => '', | |
54 | 'registered_by_id' => '', | |
55 | 'discount_id' => '', | |
56 | 'fee_currency' => '', | |
57 | 'campaign_id' => '', | |
58 | 'discount_amount' => '', | |
59 | 'cart_id' => '', | |
60 | 'must_wait' => '', | |
61 | ), | |
62 | ), | |
63 | ); | |
64 | ||
fb32de45 | 65 | return $expectedResult; |
6a488035 TO |
66 | } |
67 | ||
68 | ||
69 | /* | |
70 | * This example has been generated from the API test suite. The test that created it is called | |
71 | * | |
72 | * testCreateWithCustom and can be found in | |
73 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ParticipantTest.php | |
74 | * | |
75 | * You can see the outcome of the API tests at | |
76 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
77 | * | |
78 | * To Learn about the API read | |
79 | * http://book.civicrm.org/developer/current/techniques/api/ | |
80 | * | |
81 | * and review the wiki at | |
82 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
83 | * | |
84 | * Read more about testing here | |
85 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
86 | * | |
87 | * API Standards documentation: | |
88 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
89 | */ |