CRM-15988 - Mass cleanup of api entity names to CamelCase
[civicrm-core.git] / api / v3 / examples / CustomValue / formatFieldName.php
1 <?php
2 /**
3 * Test Generated example of using custom_value get API.
4 *
5 * utilises field names
6 *
7 * @return array
8 * API result array
9 */
10 function custom_value_get_example() {
11 $params = array(
12 'id' => 2,
13 'entity_id' => 2,
14 'format.field_names' => 1,
15 );
16
17 try{
18 $result = civicrm_api3('custom_value', 'get', $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(
26 'error' => $errorMessage,
27 'error_code' => $errorCode,
28 'error_data' => $errorData,
29 );
30 }
31
32 return $result;
33 }
34
35 /**
36 * Function returns array of result expected from previous function.
37 *
38 * @return array
39 * API result array
40 */
41 function custom_value_get_expectedresult() {
42
43 $expectedResult = array(
44 'is_error' => 0,
45 'version' => 3,
46 'count' => 7,
47 'values' => array(
48 'mySingleField' => array(
49 'entity_id' => '2',
50 'latest' => 'value 1',
51 'id' => 'mySingleField',
52 ),
53 'field_12' => array(
54 'entity_id' => '2',
55 'latest' => 'value 3',
56 'id' => 'field_12',
57 '1' => 'value 2',
58 '2' => 'value 3',
59 ),
60 'field_22' => array(
61 'entity_id' => '2',
62 'latest' => '',
63 'id' => 'field_22',
64 '1' => 'warm beer',
65 '2' => '',
66 ),
67 'field_32' => array(
68 'entity_id' => '2',
69 'latest' => '',
70 'id' => 'field_32',
71 '1' => 'fl* w*',
72 '2' => '',
73 ),
74 'field_13' => array(
75 'entity_id' => '2',
76 'latest' => 'coffee',
77 'id' => 'field_13',
78 '1' => 'defaultValue',
79 '2' => 'coffee',
80 ),
81 'field_23' => array(
82 'entity_id' => '2',
83 'latest' => 'value 4',
84 'id' => 'field_23',
85 '1' => '',
86 '2' => 'value 4',
87 ),
88 'field_33' => array(
89 'entity_id' => '2',
90 'latest' => '',
91 'id' => 'field_33',
92 '1' => 'vegemite',
93 '2' => '',
94 ),
95 ),
96 );
97
98 return $expectedResult;
99 }
100
101 /**
102 * This example has been generated from the API test suite.
103 * The test that created it is called
104 * testGetMultipleCustomValues
105 * and can be found in
106 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomValueTest.php
107 *
108 * You can see the outcome of the API tests at
109 * https://test.civicrm.org/job/CiviCRM-master-git/
110 *
111 * To Learn about the API read
112 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
113 *
114 * Browse the api on your own site with the api explorer
115 * http://MYSITE.ORG/path/to/civicrm/api
116 *
117 * Read more about testing here
118 * http://wiki.civicrm.org/confluence/display/CRM/Testing
119 *
120 * API Standards documentation:
121 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
122 */