Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-25-11-27-40
[civicrm-core.git] / api / v3 / examples / OptionGroup / Get.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the OptionGroup.get API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function option_group_get_example() {
9 $params = array(
10 'name' => 'preferred_communication_method',
11 );
6a488035 12
50fb255d 13 try{
a828d7b8 14 $result = civicrm_api3('OptionGroup', '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_group_get_expectedresult() {
6a488035 38
53ca8fd7 39 $expectedResult = array(
50fb255d 40 'is_error' => 0,
41 'version' => 3,
42 'count' => 1,
43 'id' => 1,
44 'values' => array(
53ca8fd7 45 '1' => array(
50fb255d 46 'id' => '1',
47 'name' => 'preferred_communication_method',
48 'title' => 'Preferred Communication Method',
49 'is_reserved' => '1',
50 'is_active' => '1',
51 'is_locked' => 0,
52 ),
6a488035 53 ),
50fb255d 54 );
6a488035 55
fb32de45 56 return $expectedResult;
6a488035
TO
57}
58
a828d7b8 59/*
50fb255d 60* This example has been generated from the API test suite.
a828d7b8
CW
61* The test that created it is called "testGetOptionGroupByName"
62* and can be found at:
69d79249 63* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OptionGroupTest.php
6a488035
TO
64*
65* You can see the outcome of the API tests at
69d79249 66* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
67*
68* To Learn about the API read
69d79249 69* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 70*
69d79249 71* Browse the api on your own site with the api explorer
41d4d31f 72* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
73*
74* Read more about testing here
75* http://wiki.civicrm.org/confluence/display/CRM/Testing
76*
77* API Standards documentation:
78* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 79*/