CRM-15904 - Unit test to illustrate the issue.
authorJohan Vervloet <johanv@johanv.org>
Mon, 2 Feb 2015 13:21:43 +0000 (14:21 +0100)
committereileenmcnaughton <eileen@fuzion.co.nz>
Wed, 5 Aug 2015 10:26:10 +0000 (10:26 +0000)
This unit test illustrates the problem.

I use chaining to create a contact and an e-mail address. If I do
this with sequential=1 and the reload option, I get an error.

Obviously this pull request will cause errors during automatic
testing.

----------------------------------------
* CRM-15904: API: Reload option does not work with chaining and sequential
  https://issues.civicrm.org/jira/browse/CRM-15904

tests/phpunit/CRM/Utils/API/ReloadOptionTest.php

index e83e4b17164e5d7078072b5a626a04a9cd033a5b..45d0b5ef2f3a0df4dcc512930b3a22470e6f5316 100644 (file)
@@ -87,6 +87,29 @@ class CRM_Utils_API_ReloadOptionTest extends CiviUnitTestCase {
     $this->assertAPISuccess($result['values'][$result['id']]['api.Email.create']);
   }
 
+  /**
+   * When the reload option is combined with chaining, the reload should munge
+   * the chain results, even if sequential=1.
+   */
+  public function testReloadNoChainInterferenceSequential() {
+    $result = $this->callAPISuccess('contact', 'create', array(
+      'sequential' => 1,
+      'contact_type' => 'Individual',
+      'first_name' => 'First',
+      'last_name' => 'Last',
+      'nick_name' => 'Firstie',
+      'api.Email.create' => array(
+        'email' => 'test@example.com',
+      ),
+      'options' => array(
+        'reload' => 1,
+      ),
+    ));
+    $this->assertEquals('First', $result['values'][0]['first_name']);
+    $this->assertEquals('munged', $result['values'][0]['nick_name']);
+    $this->assertAPISuccess($result['values'][0]['api.Email.create']);
+  }
+
   /**
    * An implementation of hook_civicrm_post used with all our test cases.
    *