From 5b1c3feece638c7c865ba6c412509d3427d7f71a Mon Sep 17 00:00:00 2001 From: Vinu Varshith S Date: Mon, 13 Nov 2017 16:50:14 +0530 Subject: [PATCH] Adding test cases for CRM-21041 --- tests/phpunit/api/v3/ContactTest.php | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index c2f4f94e21..f80efd65da 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -3548,4 +3548,38 @@ class api_v3_ContactTest extends CiviUnitTestCase { Civi::$statics['CRM_Contact_BAO_GroupContactCache']['is_refresh_init'] = FALSE; } + /** + * CRM-21041 Test if 'communication style' is set to site default if not passed. + */ + public function testCreateCommunicationStyleUnset() { + $this->callAPISuccess('Contact', 'create', array( + 'first_name' => 'John', + 'last_name' => 'Doe', + 'contact_type' => 'Individual') + ); + $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Doe')); + $this->assertEquals(1, $result['communication_style_id']); + } + + /** + * CRM-21041 Test if 'communication style' is set if value is passed. + */ + public function testCreateCommunicationStylePassed() { + $this->callAPISuccess('Contact', 'create', array( + 'first_name' => 'John', + 'last_name' => 'Doe', + 'contact_type' => 'Individual', + 'communication_style_id' => 'Familiar', + )); + $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Doe')); + $params = array( + 'option_group_id' => 'communication_style', + 'label' => 'Familiar', + 'return' => 'value', + ); + $optionResult = civicrm_api3('OptionValue', 'get', $params); + $communicationStyle = reset($optionResult['values']); + $this->assertEquals($communicationStyle['value'], $result['communication_style_id']); + } + } -- 2.25.1