From d719a3dfa6f2c2ab39b19d4775e915434c6a5352 Mon Sep 17 00:00:00 2001 From: Johan Vervloet Date: Mon, 2 Feb 2015 14:21:43 +0100 Subject: [PATCH] CRM-15904 - Unit test to illustrate the issue. 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 --- .../CRM/Utils/API/ReloadOptionTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php index e83e4b1716..45d0b5ef2f 100644 --- a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php @@ -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. * -- 2.25.1