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