Merge pull request #8548 from fuzionnz/CRM-18811
[civicrm-core.git] / api / v3 / examples / OptionValue / Get.php
1 <?php
2 /**
3 * Test Generated example demonstrating the OptionValue.get API.
4 *
5 * @return array
6 * API result array
7 */
8 function option_value_get_example() {
9 $params = array(
10 'option_group_id' => 1,
11 );
12
13 try{
14 $result = civicrm_api3('OptionValue', '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(
22 'is_error' => 1,
23 'error_message' => $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 'name' => 'Phone',
51 'filter' => 0,
52 'weight' => '1',
53 'is_optgroup' => 0,
54 'is_reserved' => 0,
55 'is_active' => '1',
56 ),
57 '2' => array(
58 'id' => '2',
59 'option_group_id' => '1',
60 'label' => 'Email',
61 'value' => '2',
62 'name' => 'Email',
63 'filter' => 0,
64 'weight' => '2',
65 'is_optgroup' => 0,
66 'is_reserved' => 0,
67 'is_active' => '1',
68 ),
69 '3' => array(
70 'id' => '3',
71 'option_group_id' => '1',
72 'label' => 'Postal Mail',
73 'value' => '3',
74 'name' => 'Postal Mail',
75 'filter' => 0,
76 'weight' => '3',
77 'is_optgroup' => 0,
78 'is_reserved' => 0,
79 'is_active' => '1',
80 ),
81 '4' => array(
82 'id' => '4',
83 'option_group_id' => '1',
84 'label' => 'SMS',
85 'value' => '4',
86 'name' => 'SMS',
87 'filter' => 0,
88 'weight' => '4',
89 'is_optgroup' => 0,
90 'is_reserved' => 0,
91 'is_active' => '1',
92 ),
93 '5' => array(
94 'id' => '5',
95 'option_group_id' => '1',
96 'label' => 'Fax',
97 'value' => '5',
98 'name' => 'Fax',
99 'filter' => 0,
100 'weight' => '5',
101 'is_optgroup' => 0,
102 'is_reserved' => 0,
103 'is_active' => '1',
104 ),
105 ),
106 );
107
108 return $expectedResult;
109 }
110
111 /*
112 * This example has been generated from the API test suite.
113 * The test that created it is called "testGetOptionGroup"
114 * and can be found at:
115 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OptionValueTest.php
116 *
117 * You can see the outcome of the API tests at
118 * https://test.civicrm.org/job/CiviCRM-master-git/
119 *
120 * To Learn about the API read
121 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
122 *
123 * Browse the api on your own site with the api explorer
124 * http://MYSITE.ORG/path/to/civicrm/api
125 *
126 * Read more about testing here
127 * http://wiki.civicrm.org/confluence/display/CRM/Testing
128 *
129 * API Standards documentation:
130 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
131 */