From a77b03807d5f6b5a44055c08bede01d7c5ed0f98 Mon Sep 17 00:00:00 2001 From: Johan Vervloet Date: Sat, 24 Jan 2015 22:20:27 +0100 Subject: [PATCH] Unit test for CRM-15815. ---------------------------------------- * CRM-15815: Two chained create calls, with the first one creating an array https://issues.civicrm.org/jira/browse/CRM-15815 --- tests/phpunit/api/v3/ContactTest.php | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 25244cc61c..b54a4a80a6 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -1701,6 +1701,47 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals("http://civicrm.org", $result['values'][$result['id']]['api.website.get']['values'][0]['url']); } + /** + * Verify attempt to create individual with chained arrays and sequential. + * + * See https://issues.civicrm.org/jira/browse/CRM-15815 + */ + public function testCreateIndividualWithChainedArrayAndSequential() { + $params = array( + 'sequential' => 1, + 'first_name' => 'abc5', + 'last_name' => 'xyz5', + 'contact_type' => 'Individual', + 'email' => 'woman5@yahoo.com', + 'api.phone.create' => array( + array('phone' => '03-231 07 95'), + array('phone' => '03-232 51 62'), + ), + 'api.website.create' => array( + 'url' => 'http://civicrm.org', + ), + ); + $result = $this->callAPISuccess('Contact', 'create', $params); + + // I could try to parse the result to see whether the two phone numbers + // and the website are there, but I am not sure about the correct format. + // So I will just fetch it again before checking. + // See also http://forum.civicrm.org/index.php/topic,35393.0.html + $params = array( + 'sequential' => 1, + 'id' => $result['id'], + 'api.website.get' => array(), + 'api.phone.get' => array(), + ); + $result = $this->callAPISuccess('Contact', 'get', $params); + + // delete the contact + $this->callAPISuccess('contact', 'delete', $result); + + $this->assertEquals(2, $result['values'][0]['api.phone.get']['count']); + $this->assertEquals(1, $result['values'][0]['api.website.get']['count']); + } + public function testGetIndividualWithChainedArraysFormats() { $description = "This demonstrates the usage of chained api functions.\nIn this case no notes or custom fields have been created."; $subfile = "APIChainedArrayFormats"; -- 2.25.1