From 265cc07dc4bd10d17442917236714a7c07465816 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 5 Sep 2013 20:39:21 +1200 Subject: [PATCH] CRM-13252 attempt to replicate multiple phone create --- tests/phpunit/api/v3/ContactTest.php | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 1b03b4f7c8..a982e88411 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -1203,6 +1203,49 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals('testGetByUsername', $result['values'][$cid]['first_name']); } + /** + * Test to check return works OK + */ + function testContactGetReturnValues() { + $extraParams = array('nick_name' => 'Bob', 'phone' => '456', 'email' => 'e@mail.com'); + $contactID = $this->individualCreate($extraParams); + //actually it turns out the above doesn't create a phone + $phones = $this->callAPISuccess('phone', 'create', array('contact_id' => $contactID, 'phone' => '456',)); + $result = $this->callAPISuccess('contact', 'getsingle', array('id' => $contactID)); + foreach ($extraParams as $key => $value) { + $this->assertEquals($result[$key], $value); + } + //now we check they are still returned with 'return' key + $result = $this->callAPISuccess('contact', 'getsingle', array('id' => $contactID, 'return' => array_keys($extraParams))); + foreach ($extraParams as $key => $value) { + $this->assertEquals($result[$key], $value); + } + } + + function testCRM13252MultipleChainedPhones() { + $contactID = $this->householdCreate(); + $this->callAPISuccessGetCount('phone', array('contact_id' => $contactID), 0); + $params = array( + 'contact_id' => $contactID, + 'household_name' => 'Household 1', + 'contact_type' => 'Household', + 'api.phone.create' => array( + 0 => array( + 'phone' => '111-111-1111', + 'location_type_id' => 1, + 'phone_type_id' => 1, + ), + 1 => array( + 'phone' => '222-222-2222', + 'location_type_id' => 1, + 'phone_type_id' => 2, + ) + ) + ); + $result = $this->callAPISuccess('contact', 'create', $params); + $this->callAPISuccessGetCount('phone', array('contact_id' => $contactID), 2); + + } /** * Test for Contact.get id=@user:username (with an invalid username) */ -- 2.25.1