Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / OptionGroup / Create.php
index 3475f44eb52e55ca6adde9e5735fa5a568eb3013..b44190696a358959413f28352c483823ff18f370 100644 (file)
@@ -1,39 +1,39 @@
 <?php
 /**
- * Test Generated example of using option_group create API.
- *
+ * Test Generated example demonstrating the OptionGroup.create API.
  *
  * @return array
  *   API result array
  */
 function option_group_create_example() {
-  $params = array(
+  $params = [
     'sequential' => 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