Merge branch 'crm-13089-CRM_Core_BAO_CustomField_overrides_name' of git://github...
[civicrm-core.git] / api / v3 / examples / OptionValueGet.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using option_value get API
4 * *
6a488035
TO
5 */
6function option_value_get_example(){
53ca8fd7 7$params = array(
6a488035 8 'option_group_id' => 1,
6a488035
TO
9);
10
fb32de45 11try{
12 $result = civicrm_api3('option_value', 'get', $params);
13}
14catch (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}
6a488035 21
fb32de45 22return $result;
6a488035
TO
23}
24
fb32de45 25/**
6a488035
TO
26 * Function returns array of result expected from previous function
27 */
28function option_value_get_expectedresult(){
29
53ca8fd7 30 $expectedResult = array(
6a488035
TO
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 5,
53ca8fd7 34 'values' => array(
35 '1' => array(
6a488035
TO
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 ),
53ca8fd7 46 '2' => array(
6a488035
TO
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 ),
53ca8fd7 57 '3' => array(
6a488035
TO
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 ),
53ca8fd7 68 '4' => array(
6a488035
TO
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 ),
53ca8fd7 79 '5' => array(
6a488035
TO
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
fb32de45 93 return $expectedResult;
6a488035
TO
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*/