Merge pull request #3679 from yashodha/CRM-14951
[civicrm-core.git] / api / v3 / examples / Batch / Update.php
1 <?php
2 /**
3 * Test Generated example of using batch update API
4 * *
5 */
6 function batch_update_example(){
7 $params = array(
8 'name' => 'New_Batch_04',
9 'title' => 'New Batch 04',
10 'description' => 'This is description for New Batch 04',
11 'total' => '400.44',
12 'item_count' => 4,
13 'id' => 1,
14 );
15
16 try{
17 $result = civicrm_api3('batch', 'update', $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 }
26
27 return $result;
28 }
29
30 /**
31 * Function returns array of result expected from previous function
32 */
33 function batch_update_expectedresult(){
34
35 $expectedResult = array(
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
39 'id' => 1,
40 'values' => array(
41 '1' => array(
42 'id' => '1',
43 'name' => 'New_Batch_04',
44 'title' => 'New Batch 04',
45 'description' => 'This is description for New Batch 04',
46 'created_id' => '',
47 'created_date' => '',
48 'modified_id' => '',
49 'modified_date' => '',
50 'saved_search_id' => '',
51 'status_id' => '',
52 'type_id' => '',
53 'mode_id' => '',
54 'total' => '400.44',
55 'item_count' => '4',
56 'payment_instrument_id' => '',
57 'exported_date' => '',
58 'data' => '',
59 ),
60 ),
61 );
62
63 return $expectedResult;
64 }
65
66
67 /*
68 * This example has been generated from the API test suite. The test that created it is called
69 *
70 * testUpdate and can be found in
71 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php
72 *
73 * You can see the outcome of the API tests at
74 * https://test.civicrm.org/job/CiviCRM-master-git/
75 *
76 * To Learn about the API read
77 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
78 *
79 * Browse the api on your own site with the api explorer
80 * http://MYSITE.ORG/path/to/civicrm/api/explorer
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
87 */