Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using custom_value get API | |
4 | * utilises field names * | |
6a488035 TO |
5 | */ |
6 | function custom_value_get_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 | 8 | 'id' => 2, |
6a488035 TO |
9 | 'entity_id' => 2, |
10 | 'format.field_names' => 1, | |
11 | ); | |
12 | ||
fb32de45 | 13 | try{ |
14 | $result = civicrm_api3('custom_value', 'get', $params); | |
15 | } | |
16 | catch (CiviCRM_API3_Exception $e) { | |
17 | // handle error here | |
18 | $errorMessage = $e->getMessage(); | |
19 | $errorCode = $e->getErrorCode(); | |
20 | $errorData = $e->getExtraParams(); | |
21 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
22 | } | |
6a488035 | 23 | |
fb32de45 | 24 | return $result; |
6a488035 TO |
25 | } |
26 | ||
fb32de45 | 27 | /** |
6a488035 TO |
28 | * Function returns array of result expected from previous function |
29 | */ | |
30 | function custom_value_get_expectedresult(){ | |
31 | ||
53ca8fd7 | 32 | $expectedResult = array( |
6a488035 TO |
33 | 'is_error' => 0, |
34 | 'version' => 3, | |
b422b715 | 35 | 'count' => 7, |
53ca8fd7 | 36 | 'values' => array( |
37 | 'mySingleField' => array( | |
6a488035 TO |
38 | 'entity_id' => '2', |
39 | 'latest' => 'value 1', | |
40 | 'id' => 'mySingleField', | |
6a488035 | 41 | ), |
b422b715 | 42 | 'field_12' => array( |
43 | 'entity_id' => '2', | |
44 | 'latest' => 'value 3', | |
45 | 'id' => 'field_12', | |
46 | '1' => 'value 2', | |
47 | '2' => 'value 3', | |
48 | ), | |
49 | 'field_22' => array( | |
50 | 'entity_id' => '2', | |
51 | 'latest' => '', | |
52 | 'id' => 'field_22', | |
53 | '1' => 'warm beer', | |
54 | '2' => '', | |
55 | ), | |
56 | 'field_32' => array( | |
57 | 'entity_id' => '2', | |
58 | 'latest' => '', | |
59 | 'id' => 'field_32', | |
60 | '1' => 'fl* w*', | |
61 | '2' => '', | |
62 | ), | |
63 | 'field_13' => array( | |
6a488035 TO |
64 | 'entity_id' => '2', |
65 | 'latest' => 'coffee', | |
b422b715 | 66 | 'id' => 'field_13', |
67 | '1' => 'defaultValue', | |
6a488035 TO |
68 | '2' => 'coffee', |
69 | ), | |
b422b715 | 70 | 'field_23' => array( |
6a488035 TO |
71 | 'entity_id' => '2', |
72 | 'latest' => 'value 4', | |
b422b715 | 73 | 'id' => 'field_23', |
6a488035 TO |
74 | '1' => '', |
75 | '2' => 'value 4', | |
76 | ), | |
b422b715 | 77 | 'field_33' => array( |
6a488035 TO |
78 | 'entity_id' => '2', |
79 | 'latest' => '', | |
b422b715 | 80 | 'id' => 'field_33', |
6a488035 TO |
81 | '1' => 'vegemite', |
82 | '2' => '', | |
83 | ), | |
84 | ), | |
85 | ); | |
86 | ||
fb32de45 | 87 | return $expectedResult; |
6a488035 TO |
88 | } |
89 | ||
90 | ||
91 | /* | |
92 | * This example has been generated from the API test suite. The test that created it is called | |
93 | * | |
94 | * testGetMultipleCustomValues and can be found in | |
95 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/CustomValueTest.php | |
96 | * | |
97 | * You can see the outcome of the API tests at | |
98 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
99 | * | |
100 | * To Learn about the API read | |
101 | * http://book.civicrm.org/developer/current/techniques/api/ | |
102 | * | |
103 | * and review the wiki at | |
104 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
105 | * | |
106 | * Read more about testing here | |
107 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
108 | * | |
109 | * API Standards documentation: | |
110 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
111 | */ |