3 * Test Generated example demonstrating the OptionValue.getsingle API.
5 * Demonstrates use of Sort param (available in many api functions). Also, getsingle.
10 function option_value_getsingle_example() {
12 'option_group_id' => 1,
14 'sort' => 'label DESC',
20 $result = civicrm_api3('OptionValue', 'getsingle', $params);
22 catch (CiviCRM_API3_Exception
$e) {
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
29 'error_message' => $errorMessage,
30 'error_code' => $errorCode,
31 'error_data' => $errorData,
39 * Function returns array of result expected from previous function.
44 function option_value_getsingle_expectedresult() {
48 'option_group_id' => '1',
59 return $expectedResult;
63 * This example has been generated from the API test suite.
64 * The test that created it is called "testGetSingleValueOptionValueSort"
65 * and can be found at:
66 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OptionValueTest.php
68 * You can see the outcome of the API tests at
69 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
71 * To Learn about the API read
72 * https://docs.civicrm.org/dev/en/latest/api/
74 * Browse the API on your own site with the API Explorer. It is in the main
75 * CiviCRM menu, under: Support > Development > API Explorer.
77 * Read more about testing here
78 * https://docs.civicrm.org/dev/en/latest/testing/
80 * API Standards documentation:
81 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/