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