X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FOptionGroup%2FCreate.php;h=b44190696a358959413f28352c483823ff18f370;hb=cf8f0fff2d9b29aeeb6b511208054da760b4d544;hp=3475f44eb52e55ca6adde9e5735fa5a568eb3013;hpb=aef6568a815f3e4466287a87c4967196199147f1;p=civicrm-core.git diff --git a/api/v3/examples/OptionGroup/Create.php b/api/v3/examples/OptionGroup/Create.php index 3475f44eb5..b44190696a 100644 --- a/api/v3/examples/OptionGroup/Create.php +++ b/api/v3/examples/OptionGroup/Create.php @@ -1,39 +1,39 @@ 1, 'name' => 'civicrm_event.amount.560', 'is_reserved' => 1, 'is_active' => 1, - 'api.OptionValue.create' => array( + 'api.OptionValue.create' => [ 'label' => 'workshop', 'value' => 35, 'is_default' => 1, 'is_active' => 1, 'format.only_id' => 1, - ), - ); + ], + ]; try{ - $result = civicrm_api3('option_group', 'create', $params); + $result = civicrm_api3('OptionGroup', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. $errorMessage = $e->getMessage(); $errorCode = $e->getErrorCode(); $errorData = $e->getExtraParams(); - return array( - 'error' => $errorMessage, + return [ + 'is_error' => 1, + 'error_message' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData, - ); + ]; } return $result; @@ -47,33 +47,33 @@ function option_group_create_example() { */ function option_group_create_expectedresult() { - $expectedResult = array( + $expectedResult = [ 'is_error' => 0, 'version' => 3, 'count' => 1, 'id' => 92, - 'values' => array( - '0' => array( + 'values' => [ + '0' => [ 'id' => '92', 'name' => 'civicrm_event.amount.560', 'title' => '', 'description' => '', + 'data_type' => '', 'is_reserved' => '1', 'is_active' => '1', 'is_locked' => '', - 'api.OptionValue.create' => 780, - ), - ), - ); + 'api.OptionValue.create' => 849, + ], + ], + ]; return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testGetOptionCreateSuccess -* and can be found in +* The test that created it is called "testGetOptionCreateSuccess" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OptionGroupTest.php * * You can see the outcome of the API tests at