CRM-13072 more test class upgrades
[civicrm-core.git] / api / v3 / examples / MailingCreate.php
index 8ef2f999f946e7f8fa8e948bab1f7ad357ae2219..7fab57269cbec9afe2878d450d4a4ebef5562a99 100644 (file)
@@ -1,23 +1,31 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mailing create API
+ * *
  */
 function mailing_create_example(){
 $params = array(
   'subject' => 'maild',
   'body_text' => 'bdkfhdskfhduew',
-  'version' => 3,
   'name' => 'mailing name',
   'created_id' => 1,
 );
 
-  $result = civicrm_api( 'mailing','create',$params );
+try{
+  $result = civicrm_api3('mailing', '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 mailing_create_expectedresult(){
@@ -52,11 +60,11 @@ function mailing_create_expectedresult(){
           'msg_template_id' => '',
           'override_verp' => '1',
           'created_id' => '1',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 05:52:14',
           'scheduled_id' => '',
-          'scheduled_date' => '20130622085501',
+          'scheduled_date' => '20130728085413',
           'approver_id' => '1',
-          'approval_date' => '20130622085501',
+          'approval_date' => '20130728085413',
           'approval_status_id' => '',
           'approval_note' => '',
           'is_archived' => '',
@@ -73,7 +81,7 @@ function mailing_create_expectedresult(){
                   '0' => array(
                       'id' => '1',
                       'mailing_id' => '1',
-                      'scheduled_date' => '20130622085501',
+                      'scheduled_date' => '20130728085413',
                       'start_date' => '',
                       'end_date' => '',
                       'status' => 'Scheduled',
@@ -89,7 +97,7 @@ function mailing_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }