Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using batch create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function batch_create_example(){ | |
edb0d67a | 7 | $params = array( |
6a488035 TO |
8 | 'name' => 'New_Batch_03', |
9 | 'title' => 'New Batch 03', | |
10 | 'description' => 'This is description for New Batch 03', | |
11 | 'total' => '300.33', | |
12 | 'item_count' => 3, | |
13 | 'status_id' => 1, | |
6a488035 TO |
14 | ); |
15 | ||
fb32de45 | 16 | try{ |
17 | $result = civicrm_api3('batch', 'create', $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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
25 | } | |
6a488035 | 26 | |
fb32de45 | 27 | return $result; |
6a488035 TO |
28 | } |
29 | ||
fb32de45 | 30 | /** |
6a488035 TO |
31 | * Function returns array of result expected from previous function |
32 | */ | |
33 | function batch_create_expectedresult(){ | |
34 | ||
edb0d67a | 35 | $expectedResult = array( |
6a488035 TO |
36 | 'is_error' => 0, |
37 | 'version' => 3, | |
38 | 'count' => 1, | |
edb0d67a | 39 | 'id' => 1, |
40 | 'values' => array( | |
41 | '1' => array( | |
42 | 'id' => '1', | |
6a488035 TO |
43 | 'name' => 'New_Batch_03', |
44 | 'title' => 'New Batch 03', | |
45 | 'description' => 'This is description for New Batch 03', | |
46 | 'created_id' => '', | |
9f1b81e0 | 47 | 'created_date' => '', |
6a488035 | 48 | 'modified_id' => '', |
b259a4ab | 49 | 'modified_date' => '2012-11-14 16:02:35', |
6a488035 TO |
50 | 'saved_search_id' => '', |
51 | 'status_id' => '1', | |
52 | 'type_id' => '', | |
53 | 'mode_id' => '', | |
54 | 'total' => '300.33', | |
55 | 'item_count' => '3', | |
56 | 'payment_instrument_id' => '', | |
57 | 'exported_date' => '', | |
b259a4ab | 58 | 'data' => '', |
6a488035 TO |
59 | ), |
60 | ), | |
61 | ); | |
62 | ||
fb32de45 | 63 | return $expectedResult; |
6a488035 TO |
64 | } |
65 | ||
66 | ||
67 | /* | |
68 | * This example has been generated from the API test suite. The test that created it is called | |
69 | * | |
70 | * testCreate and can be found in | |
69d79249 | 71 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php |
6a488035 TO |
72 | * |
73 | * You can see the outcome of the API tests at | |
69d79249 | 74 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
75 | * |
76 | * To Learn about the API read | |
69d79249 | 77 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 78 | * |
69d79249 E |
79 | * Browse the api on your own site with the api explorer |
80 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
81 | * |
82 | * Read more about testing here | |
83 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
84 | * | |
85 | * API Standards documentation: | |
86 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 87 | */ |