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