Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-09-11-44-07
[civicrm-core.git] / api / v3 / examples / OptionValue / Get.php
1 <?php
2 /**
3 * Test Generated example of using option_value get API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9 function option_value_get_example() {
10 $params = array(
11 'option_group_id' => 1,
12 );
13
14 try{
15 $result = civicrm_api3('option_value', 'get', $params);
16 }
17 catch (CiviCRM_API3_Exception $e) {
18 // Handle error here.
19 $errorMessage = $e->getMessage();
20 $errorCode = $e->getErrorCode();
21 $errorData = $e->getExtraParams();
22 return array(
23 'error' => $errorMessage,
24 'error_code' => $errorCode,
25 'error_data' => $errorData,
26 );
27 }
28
29 return $result;
30 }
31
32 /**
33 * Function returns array of result expected from previous function.
34 *
35 * @return array
36 * API result array
37 */
38 function option_value_get_expectedresult() {
39
40 $expectedResult = array(
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 5,
44 'values' => array(
45 '1' => array(
46 'id' => '1',
47 'option_group_id' => '1',
48 'label' => 'Phone',
49 'value' => '1',
50 'filter' => 0,
51 'weight' => '1',
52 'is_optgroup' => 0,
53 'is_reserved' => 0,
54 'is_active' => '1',
55 ),
56 '2' => array(
57 'id' => '2',
58 'option_group_id' => '1',
59 'label' => 'Email',
60 'value' => '2',
61 'filter' => 0,
62 'weight' => '2',
63 'is_optgroup' => 0,
64 'is_reserved' => 0,
65 'is_active' => '1',
66 ),
67 '3' => array(
68 'id' => '3',
69 'option_group_id' => '1',
70 'label' => 'Postal Mail',
71 'value' => '3',
72 'filter' => 0,
73 'weight' => '3',
74 'is_optgroup' => 0,
75 'is_reserved' => 0,
76 'is_active' => '1',
77 ),
78 '4' => array(
79 'id' => '4',
80 'option_group_id' => '1',
81 'label' => 'SMS',
82 'value' => '4',
83 'filter' => 0,
84 'weight' => '4',
85 'is_optgroup' => 0,
86 'is_reserved' => 0,
87 'is_active' => '1',
88 ),
89 '5' => array(
90 'id' => '5',
91 'option_group_id' => '1',
92 'label' => 'Fax',
93 'value' => '5',
94 'filter' => 0,
95 'weight' => '5',
96 'is_optgroup' => 0,
97 'is_reserved' => 0,
98 'is_active' => '1',
99 ),
100 ),
101 );
102
103 return $expectedResult;
104 }
105
106 /**
107 * This example has been generated from the API test suite.
108 * The test that created it is called
109 * testGetOptionGroup
110 * and can be found in
111 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OptionValueTest.php
112 *
113 * You can see the outcome of the API tests at
114 * https://test.civicrm.org/job/CiviCRM-master-git/
115 *
116 * To Learn about the API read
117 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
118 *
119 * Browse the api on your own site with the api explorer
120 * http://MYSITE.ORG/path/to/civicrm/api
121 *
122 * Read more about testing here
123 * http://wiki.civicrm.org/confluence/display/CRM/Testing
124 *
125 * API Standards documentation:
126 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
127 */