CRM-15891 - Unit test to illustrate the problem.
authorJohan Vervloet <johanv@johanv.org>
Mon, 2 Feb 2015 12:23:15 +0000 (13:23 +0100)
committereileenmcnaugton <eileen@fuzion.co.nz>
Wed, 5 Aug 2015 10:48:36 +0000 (22:48 +1200)
If I use the api to create a contact and two websites, I expect the
result values to contain the array key 'api.website.create' to be
there.

----------------------------------------
* CRM-15891: Inconsistency in returned json for chained get and chained create
  https://issues.civicrm.org/jira/browse/CRM-15891

Conflicts:
tests/phpunit/api/v3/ContactTest.php

tests/phpunit/api/v3/ContactTest.php

index b54a4a80a6255cdb85035926abab8f07dc9ea81c..787583fb3ae8411885514b1a62c8c5f7ca817e5c 100644 (file)
@@ -1634,7 +1634,46 @@ class api_v3_ContactTest extends CiviUnitTestCase {
   }
 
   /**
-   * Verify attempt to create individual with chained arrays.
+   *  Verify attempt to create individual with chained arrays and sequential
+   */
+  public function testGetIndividualWithChainedArraysAndSequential() {
+    $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
+    $params['custom_' . $ids['custom_field_id']] = "custom string";
+
+    $moreids = $this->CustomGroupMultipleCreateWithFields();
+    $description = "/*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created ";
+    $subfile = "APIChainedArray";
+    $params = array(
+      'sequential' => 1,
+      'first_name' => 'abc3',
+      'last_name' => 'xyz3',
+      'contact_type' => 'Individual',
+      'email' => 'man3@yahoo.com',
+      'api.website.create' => array(
+        array(
+          'url' => "http://civicrm.org",
+        ),
+        array(
+          'url' => "https://civicrm.org",
+        ),
+      ),
+    );
+
+    $result = $this->callAPISuccess('Contact', 'create', $params);
+
+    file_put_contents('/tmp/out.txt', print_r($result, true));
+
+    // delete the contact and custom groups
+    $this->callAPISuccess('contact', 'delete', array('id' => $result['id']));
+    $this->customGroupDelete($ids['custom_group_id']);
+    $this->customGroupDelete($moreids['custom_group_id']);
+
+    $this->assertEquals($result['id'], $result['values'][0]['id']);
+    $this->assertArrayKeyExists('api.website.create', $result['values'][0]);
+  }
+
+  /**
+   *  Verify attempt to create individual with chained arrays
    */
   public function testGetIndividualWithChainedArrays() {
     $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);