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