Merge remote-tracking branch 'upstream/4.5' into 4.5-4.6-2015-04-13-16-08-08
[civicrm-core.git] / api / v3 / examples / OptionValue / Get.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the OptionValue.get API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function option_value_get_example() {
9 $params = array(
10 'option_group_id' => 1,
11 );
6a488035 12
50fb255d 13 try{
a828d7b8 14 $result = civicrm_api3('OptionValue', 'get', $params);
50fb255d 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;
6a488035
TO
29}
30
fb32de45 31/**
50fb255d 32 * Function returns array of result expected from previous function.
33 *
34 * @return array
35 * API result array
6a488035 36 */
50fb255d 37function option_value_get_expectedresult() {
6a488035 38
53ca8fd7 39 $expectedResult = array(
50fb255d 40 'is_error' => 0,
41 'version' => 3,
42 'count' => 5,
43 'values' => array(
53ca8fd7 44 '1' => array(
50fb255d 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 ),
53ca8fd7 55 '2' => array(
50fb255d 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 ),
53ca8fd7 66 '3' => array(
50fb255d 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 ),
53ca8fd7 77 '4' => array(
50fb255d 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 ),
53ca8fd7 88 '5' => array(
50fb255d 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 ),
6a488035 99 ),
50fb255d 100 );
6a488035 101
fb32de45 102 return $expectedResult;
6a488035
TO
103}
104
a828d7b8 105/*
50fb255d 106* This example has been generated from the API test suite.
a828d7b8
CW
107* The test that created it is called "testGetOptionGroup"
108* and can be found at:
69d79249 109* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OptionValueTest.php
6a488035
TO
110*
111* You can see the outcome of the API tests at
69d79249 112* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
113*
114* To Learn about the API read
69d79249 115* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 116*
69d79249 117* Browse the api on your own site with the api explorer
41d4d31f 118* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
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
b259a4ab 125*/