Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using custom_value get API | |
4 | * /*this demonstrates the use of CustomValue get * | |
6a488035 TO |
5 | */ |
6 | function custom_value_get_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 | 8 | 'id' => 2, |
6a488035 TO |
9 | 'entity_id' => 2, |
10 | ); | |
11 | ||
fb32de45 | 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 | } | |
6a488035 | 22 | |
fb32de45 | 23 | return $result; |
6a488035 TO |
24 | } |
25 | ||
fb32de45 | 26 | /** |
6a488035 TO |
27 | * Function returns array of result expected from previous function |
28 | */ | |
29 | function custom_value_get_expectedresult(){ | |
30 | ||
53ca8fd7 | 31 | $expectedResult = array( |
6a488035 TO |
32 | 'is_error' => 0, |
33 | 'version' => 3, | |
34 | 'count' => 7, | |
53ca8fd7 | 35 | 'values' => array( |
36 | '1' => array( | |
6a488035 TO |
37 | 'entity_id' => '2', |
38 | 'latest' => 'value 1', | |
39 | 'id' => '1', | |
6a488035 | 40 | ), |
53ca8fd7 | 41 | '2' => array( |
6a488035 TO |
42 | 'entity_id' => '2', |
43 | 'latest' => 'value 3', | |
44 | 'id' => '2', | |
45 | '1' => 'value 2', | |
46 | '2' => 'value 3', | |
47 | ), | |
53ca8fd7 | 48 | '3' => array( |
6a488035 TO |
49 | 'entity_id' => '2', |
50 | 'latest' => '', | |
51 | 'id' => '3', | |
52 | '1' => 'warm beer', | |
53 | '2' => '', | |
54 | ), | |
53ca8fd7 | 55 | '4' => array( |
6a488035 TO |
56 | 'entity_id' => '2', |
57 | 'latest' => '', | |
58 | 'id' => '4', | |
59 | '1' => 'fl* w*', | |
60 | '2' => '', | |
61 | ), | |
53ca8fd7 | 62 | '5' => array( |
6a488035 TO |
63 | 'entity_id' => '2', |
64 | 'latest' => 'coffee', | |
65 | 'id' => '5', | |
b422b715 | 66 | '1' => 'defaultValue', |
6a488035 TO |
67 | '2' => 'coffee', |
68 | ), | |
53ca8fd7 | 69 | '6' => array( |
6a488035 TO |
70 | 'entity_id' => '2', |
71 | 'latest' => 'value 4', | |
72 | 'id' => '6', | |
73 | '1' => '', | |
74 | '2' => 'value 4', | |
75 | ), | |
53ca8fd7 | 76 | '7' => array( |
6a488035 TO |
77 | 'entity_id' => '2', |
78 | 'latest' => '', | |
79 | 'id' => '7', | |
80 | '1' => 'vegemite', | |
81 | '2' => '', | |
82 | ), | |
83 | ), | |
84 | ); | |
85 | ||
fb32de45 | 86 | return $expectedResult; |
6a488035 TO |
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 | |
69d79249 | 94 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomValueTest.php |
6a488035 TO |
95 | * |
96 | * You can see the outcome of the API tests at | |
69d79249 | 97 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
98 | * |
99 | * To Learn about the API read | |
69d79249 | 100 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 101 | * |
69d79249 E |
102 | * Browse the api on your own site with the api explorer |
103 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
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 | |
b259a4ab | 110 | */ |