test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / LocBlockCreateEntities.php
index a71bf66096557a013d3dcd866250aabc6887725e..7d28bce873eb63ccfa0b5ffb612eae0b8b7a9391 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
- Create entities and location block in 1 api call
+/**
+ * Test Generated example of using loc_block createEntities API
+ * Create entities and location block in 1 api call *
  */
 function loc_block_createentities_example(){
 $params = array(
@@ -21,16 +21,23 @@ $params = array(
       'location_type_id' => 1,
       'street_address' => '987654321',
     ),
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'loc_block','createEntities',$params );
+try{
+  $result = civicrm_api3('loc_block', 'createEntities', $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 loc_block_createentities_expectedresult(){
@@ -52,7 +59,7 @@ function loc_block_createentities_expectedresult(){
             ),
           'email' => array(
               'id' => '4',
-              'contact_id' => 'null',
+              'contact_id' => '',
               'location_type_id' => '1',
               'email' => 'test2@loc.block',
               'is_primary' => 0,
@@ -66,7 +73,7 @@ function loc_block_createentities_expectedresult(){
             ),
           'phone' => array(
               'id' => '3',
-              'contact_id' => 'null',
+              'contact_id' => '',
               'location_type_id' => '1',
               'is_primary' => 0,
               'is_billing' => '',
@@ -78,7 +85,7 @@ function loc_block_createentities_expectedresult(){
             ),
           'phone_2' => array(
               'id' => '4',
-              'contact_id' => 'null',
+              'contact_id' => '',
               'location_type_id' => '1',
               'is_primary' => 0,
               'is_billing' => '',
@@ -101,7 +108,7 @@ function loc_block_createentities_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }