Merge pull request #10155 from totten/master-pdf-save2
[civicrm-core.git] / api / v3 / examples / Contact / APIChainedArrayValuesFromSiblingFunction.php
index 99486a32ae16ed4dec4d7172beba31a4860cfcaa..6bca265586b6a07580e2d29c5694e23008c542fc 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /**
- * Test Generated example of using contact create API.
+ * Test Generated example demonstrating the Contact.create API.
  *
- * /*this demonstrates the usage of chained api functions.  Specifically it has one 'parent function' &
-    2 child functions - one receives values from the parent (Contact) and the other child (Tag). 
+ * This demonstrates the usage of chained api functions.  Specifically it has one 'parent function' &
+ * 2 child functions - one receives values from the parent (Contact) and the other child (Tag).
  *
  * @return array
  *   API result array
@@ -23,7 +23,7 @@ function contact_create_example() {
   );
 
   try{
-    $result = civicrm_api3('contact', 'create', $params);
+    $result = civicrm_api3('Contact', 'create', $params);
   }
   catch (CiviCRM_API3_Exception $e) {
     // Handle error here.
@@ -31,7 +31,8 @@ function contact_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -52,10 +53,10 @@ function contact_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'id' => '1',
+      '3' => array(
+        'id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'do_not_email' => 0,
@@ -66,7 +67,7 @@ function contact_create_expectedresult() {
         'is_opt_out' => 0,
         'legal_identifier' => '',
         'external_identifier' => '',
-        'sort_name' => '',
+        'sort_name' => 'batman',
         'display_name' => 'batman',
         'nick_name' => '',
         'legal_name' => '',
@@ -118,11 +119,10 @@ function contact_create_expectedresult() {
   return $expectedResult;
 }
 
-/**
+/*
 * This example has been generated from the API test suite.
-* The test that created it is called
-* testChainingValuesCreate
-* and can be found in
+* The test that created it is called "testChainingValuesCreate"
+* and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
 *
 * You can see the outcome of the API tests at