From 6fdc0e61ce63e62679aa9e7489aade38aa11a7bd Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 25 Jul 2017 01:25:01 +1200 Subject: [PATCH] CRM-20953 Importing contacts with deceased_date not setting is_deceased --- CRM/Contact/Import/Parser/Contact.php | 1 + .../CRM/Contact/Import/Parser/ContactTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 9f9733b74a..d236d87bc4 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -1920,6 +1920,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } elseif ($key == 'deceased_date' && $val) { CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key); + $params['is_deceased'] = 1; } elseif ($key == 'is_deceased' && $val) { $params[$key] = CRM_Utils_String::strtoboolstr($val); diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index c063623689..0fd4347b8c 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -183,6 +183,25 @@ class CRM_Contact_Imports_Parser_ContactTest extends CiviUnitTestCase { $this->callAPISuccess('Contact', 'delete', array('id' => $contact['id'])); } + /** + * Test that the import parser adds the address to the primary location. + * + * @throws \Exception + */ + public function testImportDeceased() { + list($contactValues) = $this->setUpBaseContact(); + CRM_Core_Session::singleton()->set("dateTypes", 1); + $contactValues['birth_date'] = '1910-12-17'; + $contactValues['deceased_date'] = '2010-12-17'; + $this->runImport($contactValues, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::VALID); + $contact = $this->callAPISuccessGetSingle('Contact', $contactValues); + $this->assertEquals('1910-12-17', $contact['birth_date']); + $this->assertEquals('2010-12-17', $contact['deceased_date']); + $this->assertEquals(1, $contact['is_deceased']); + $this->callAPISuccess('Contact', 'delete', array('id' => $contact['id'])); + } + + /** * Test that the import parser adds the address to the primary location. * -- 2.25.1