Update test examples.
[civicrm-core.git] / api / v3 / examples / Batch / Create.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Batch.create API.
4 *
5 * @return array
6 * API result array
7 */
8 function batch_create_example() {
9 $params = array(
10 'name' => 'New_Batch_04',
11 'title' => 'New Batch 04',
12 'description' => 'This is description for New Batch 04',
13 'total' => '400.44',
14 'item_count' => 4,
15 'id' => 3,
16 );
17
18 try{
19 $result = civicrm_api3('Batch', 'create', $params);
20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array(
27 'is_error' => 1,
28 'error_message' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 );
32 }
33
34 return $result;
35 }
36
37 /**
38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
42 */
43 function batch_create_expectedresult() {
44
45 $expectedResult = array(
46 'is_error' => 0,
47 'version' => 3,
48 'count' => 1,
49 'id' => 3,
50 'values' => array(
51 '3' => array(
52 'id' => '3',
53 'name' => 'New_Batch_04',
54 'title' => 'New Batch 04',
55 'description' => 'This is description for New Batch 04',
56 'created_id' => '',
57 'created_date' => '',
58 'modified_id' => '',
59 'modified_date' => '',
60 'saved_search_id' => '',
61 'status_id' => '',
62 'type_id' => '',
63 'mode_id' => '',
64 'total' => '400.44',
65 'item_count' => '4',
66 'payment_instrument_id' => '',
67 'exported_date' => '',
68 'data' => '',
69 ),
70 ),
71 );
72
73 return $expectedResult;
74 }
75
76 /*
77 * This example has been generated from the API test suite.
78 * The test that created it is called "testUpdate"
79 * and can be found at:
80 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php
81 *
82 * You can see the outcome of the API tests at
83 * https://test.civicrm.org/job/CiviCRM-master-git/
84 *
85 * To Learn about the API read
86 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
87 *
88 * Browse the api on your own site with the api explorer
89 * http://MYSITE.ORG/path/to/civicrm/api
90 *
91 * Read more about testing here
92 * http://wiki.civicrm.org/confluence/display/CRM/Testing
93 *
94 * API Standards documentation:
95 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
96 */