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