Merge pull request #5192 from colemanw/CRM-15988
[civicrm-core.git] / api / v3 / examples / Batch / Update.php
1 <?php
2 /**
3 * Test Generated example of using batch update API.
4 *
5 * @return array
6 * API result array
7 */
8 function batch_update_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', 'update', $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 'error' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
30 );
31 }
32
33 return $result;
34 }
35
36 /**
37 * Function returns array of result expected from previous function.
38 *
39 * @return array
40 * API result array
41 */
42 function batch_update_expectedresult() {
43
44 $expectedResult = array(
45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 3,
49 'values' => array(
50 '3' => array(
51 'id' => '3',
52 'name' => 'New_Batch_04',
53 'title' => 'New Batch 04',
54 'description' => 'This is description for New Batch 04',
55 'created_id' => '',
56 'created_date' => '',
57 'modified_id' => '',
58 'modified_date' => '',
59 'saved_search_id' => '',
60 'status_id' => '',
61 'type_id' => '',
62 'mode_id' => '',
63 'total' => '400.44',
64 'item_count' => '4',
65 'payment_instrument_id' => '',
66 'exported_date' => '',
67 'data' => '',
68 ),
69 ),
70 );
71
72 return $expectedResult;
73 }
74
75 /**
76 * This example has been generated from the API test suite.
77 * The test that created it is called
78 * testUpdate
79 * and can be found in
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 */