test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / TagCreate.php
index 682b6aecb338af584dcd290c2b477c4aa7904d43..dac7b87d8dac842b0ba3794a0523866a842bdaf3 100644 (file)
@@ -1,21 +1,29 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using tag create API
+ * *
  */
 function tag_create_example(){
 $params = array(
-  'name' => 'New Tag3',
-  'description' => 'This is description for New Tag 02',
-  'version' => 3,
+  'name' => 'Super Heros',
+  'description' => 'Outside undie-wearers',
 );
 
-  $result = civicrm_api( 'tag','create',$params );
+try{
+  $result = civicrm_api3('tag', 'create', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+  // handle error here
+  $errorMessage = $e->getMessage();
+  $errorCode = $e->getErrorCode();
+  $errorData = $e->getExtraParams();
+  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function tag_create_expectedresult(){
@@ -24,24 +32,24 @@ function tag_create_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 8,
+  'id' => 12,
   'values' => array(
-      '8' => array(
-          'id' => '8',
-          'name' => 'New Tag3',
-          'description' => 'This is description for New Tag 02',
+      '12' => array(
+          'id' => '12',
+          'name' => 'Super Heros',
+          'description' => 'Outside undie-wearers',
           'parent_id' => '',
           'is_selectable' => '',
           'is_reserved' => '',
           'is_tagset' => '',
           'used_for' => 'civicrm_contact',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 08:49:19',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }