/**
* Test that import parser will add contact with employee of relationship.
- *
- * @throws \Exception
*/
- public function testImportParserWtihEmployeeOfRelationship() {
+ public function testImportParserWithEmployeeOfRelationship(): void {
$this->organizationCreate([
- "organization_name" => "Agileware",
- "legal_name" => "Agileware",
+ 'organization_name' => 'Agileware',
+ 'legal_name' => 'Agileware',
]);
$contactImportValues = [
"first_name" => "Alok",
}
/**
- * Test that import parser will not fail when same external_identifier found of deleted contact.
+ * Test that import parser will not fail when same external_identifier found
+ * of deleted contact.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function testImportParserWtihDeletedContactExternalIdentifier() {
+ public function testImportParserWithDeletedContactExternalIdentifier(): void {
$contactId = $this->individualCreate([
'external_identifier' => 'ext-1',
]);
$this->callAPISuccess('Contact', 'delete', ['id' => $contactId]);
- list($originalValues, $result) = $this->setUpBaseContact([
+ [$originalValues, $result] = $this->setUpBaseContact([
'external_identifier' => 'ext-1',
]);
$originalValues['nick_name'] = 'Old Bill';
*
* In this case the contact has no external identifier.
*
- * @throws \Exception
+ * @throws \CRM_Core_Exception
*/
- public function testImportParserWithUpdateWithoutExternalIdentifier() {
- list($originalValues, $result) = $this->setUpBaseContact();
+ public function testImportParserWithUpdateWithoutExternalIdentifier(): void {
+ [$originalValues, $result] = $this->setUpBaseContact();
$originalValues['nick_name'] = 'Old Bill';
$this->runImport($originalValues, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::VALID);
$originalValues['id'] = $result['id'];
* @throws \Exception
*/
public function testImportParserWithUpdateWithExternalIdentifier() {
- list($originalValues, $result) = $this->setUpBaseContact(['external_identifier' => 'windows']);
+ [$originalValues, $result] = $this->setUpBaseContact(['external_identifier' => 'windows']);
$this->assertEquals($result['id'], CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', 'windows', 'id', 'external_identifier', TRUE));
$this->assertEquals('windows', $result['external_identifier']);
* @throws \Exception
*/
public function testImportParserWithUpdateWithExternalIdentifierButNoPrimaryMatch() {
- list($originalValues, $result) = $this->setUpBaseContact([
+ [$originalValues, $result] = $this->setUpBaseContact([
'external_identifier' => 'windows',
'email' => NULL,
]);
* @throws \Exception
*/
public function testImportParserWithUpdateWithContactID() {
- list($originalValues, $result) = $this->setUpBaseContact([
+ [$originalValues, $result] = $this->setUpBaseContact([
'external_identifier' => '',
'email' => NULL,
]);
* @throws \Exception
*/
public function testImportParserWithUpdateWithNoExternalIdentifier() {
- list($originalValues, $result) = $this->setUpBaseContact();
+ [$originalValues, $result] = $this->setUpBaseContact();
$originalValues['nick_name'] = 'Old Bill';
$originalValues['external_identifier'] = 'windows';
$this->runImport($originalValues, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::VALID);
* @throws \Exception
*/
public function testImportParserWithUpdateWithChangedExternalIdentifier() {
- list($contactValues, $result) = $this->setUpBaseContact(['external_identifier' => 'windows']);
+ [$contactValues, $result] = $this->setUpBaseContact(['external_identifier' => 'windows']);
$contact_id = $result['id'];
$contactValues['nick_name'] = 'Old Bill';
$contactValues['external_identifier'] = 'android';
* @throws \Exception
*/
public function testImportBillingAddress() {
- list($contactValues) = $this->setUpBaseContact();
+ [$contactValues] = $this->setUpBaseContact();
$contactValues['nick_name'] = 'Old Bill';
$contactValues['external_identifier'] = 'android';
$contactValues['street_address'] = 'Big Mansion';
* @throws \Exception
*/
public function testImportPrimaryAddress() {
- list($contactValues) = $this->setUpBaseContact();
+ [$contactValues] = $this->setUpBaseContact();
$contactValues['nick_name'] = 'Old Bill';
$contactValues['external_identifier'] = 'android';
$contactValues['street_address'] = 'Big Mansion';
*/
public function testAddressWithCustomData() {
$ids = $this->entityCustomGroupWithSingleFieldCreate('Address', 'AddressTest.php');
- list($contactValues) = $this->setUpBaseContact();
+ [$contactValues] = $this->setUpBaseContact();
$contactValues['nick_name'] = 'Old Bill';
$contactValues['external_identifier'] = 'android';
$contactValues['street_address'] = 'Big Mansion';
$this->assertEquals('Y', $contact[$this->getCustomFieldName('select')]);
}
+ /**
+ * Test importing in the Preferred Language Field
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testPreferredLanguageImport() {
+ $contactValues = [
+ 'first_name' => 'Bill',
+ 'last_name' => 'Gates',
+ 'email' => 'bill.gates@microsoft.com',
+ 'nick_name' => 'Billy-boy',
+ 'preferred_language' => 'English (Australia)',
+ ];
+ $this->runImport($contactValues, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::VALID, [NULL, NULL, 'Primary', NULL, NULL]);
+ }
+
/**
* Test that the import parser adds the address to the primary location.
*
* @throws \Exception
*/
public function testImportDeceased() {
- list($contactValues) = $this->setUpBaseContact();
+ [$contactValues] = $this->setUpBaseContact();
CRM_Core_Session::singleton()->set("dateTypes", 1);
$contactValues['birth_date'] = '1910-12-17';
$contactValues['deceased_date'] = '2010-12-17';
* @throws \Exception
*/
public function testImportTwoAddressFirstPrimary() {
- list($contactValues) = $this->setUpBaseContact();
+ [$contactValues] = $this->setUpBaseContact();
$contactValues['nick_name'] = 'Old Bill';
$contactValues['external_identifier'] = 'android';
$contactValues['street_address'] = 'Big Mansion';
* @throws \Exception
*/
public function testImportTwoAddressSecondPrimary() {
- list($contactValues) = $this->setUpBaseContact();
+ [$contactValues] = $this->setUpBaseContact();
$contactValues['nick_name'] = 'Old Bill';
$contactValues['external_identifier'] = 'android';
$contactValues['street_address'] = 'Big Mansion';
* @throws \Exception
*/
public function testImportPrimaryAddressUpdate() {
- list($contactValues) = $this->setUpBaseContact(['external_identifier' => 'android']);
+ [$contactValues] = $this->setUpBaseContact(['external_identifier' => 'android']);
$contactValues['email'] = 'melinda.gates@microsoft.com';
$contactValues['phone'] = '98765';
$contactValues['external_identifier'] = 'android';
/**
* CRM-19888 default country should be used if ambigous.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function testImportAmbiguousStateCountry() {
+ public function testImportAmbiguousStateCountry(): void {
$this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
$countries = CRM_Core_PseudoConstant::country(FALSE, FALSE);
$this->callAPISuccess('Setting', 'create', ['countryLimit' => [array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries)]]);
$this->callAPISuccess('Setting', 'create', ['provinceLimit' => [array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries)]]);
$mapper = [0 => NULL, 1 => NULL, 2 => 'Primary', 3 => NULL];
- list($contactValues) = $this->setUpBaseContact();
+ [$contactValues] = $this->setUpBaseContact();
$fields = array_keys($contactValues);
$addressValues = [
'street_address' => 'PO Box 2716',
* that method does not cope with duplicates.
* @param int|null $ruleGroupId
* To test against a specific dedupe rule group, pass its ID as this argument.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- protected function runImport($originalValues, $onDuplicateAction, $expectedResult, $mapperLocType = [], $fields = NULL, int $ruleGroupId = NULL) {
+ protected function runImport(array $originalValues, $onDuplicateAction, $expectedResult, $mapperLocType = [], $fields = NULL, int $ruleGroupId = NULL): void {
if (!$fields) {
$fields = array_keys($originalValues);
}