diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 41fe4b8e4b6169e31210447e2653e0369f8455ed..13b16a9ff22d9d8608875db9eef914b7c7c014ea 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -671,6 +671,7 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa } } } + continue; } switch ($key) { diff --git a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php index 753f684e71b4b67bb611bc372a661b87f886503f..e445f6e36ea5ffb6ff7f88499fe9b51b68553745 100644 --- a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php @@ -177,6 +177,25 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase { // on one hand the custom fields have a date format & on the other there is an input format & // it seems to ignore the latter in favour of the former - which seems wrong. $this->assertEquals('20191020000000', $formatted[$this->getCustomFieldName('date')]); + $this->callAPISuccess('CustomField', 'delete', ['id' => $this->ids['CustomField']['date']]); + $this->callAPISuccess('CustomGroup', 'delete', ['id' => $this->ids['CustomGroup']['Custom Group']]); + } + + public function testParsedCustomOption() { + $contactID = $this->individualCreate(); + $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type' => 'Donation', 'payment_instrument' => 'Check', 'contribution_status_id' => 'Pending']; + // Note that the expected result should logically be CRM_Import_Parser::valid but writing test to reflect not fix here + $this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, NULL); + $contribution = $this->callAPISuccess('Contribution', 'getsingle', ['contact_id' => $contactID]); + $this->createCustomGroupWithFieldOfType([], 'radio'); + $values['contribution_id'] = $contribution['id']; + $values[$this->getCustomFieldName('radio')] = 'Red Testing'; + unset(Civi::$statics['CRM_Core_BAO_OptionGroup']); + $this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, NULL); + $contribution = $this->callAPISuccess('Contribution', 'get', ['contact_id' => $contactID, $this->getCustomFieldName('radio') => 'Red Testing']); + $this->assertEquals(5, $contribution['values'][$contribution['id']]['custom_' . $this->ids['CustomField']['radio']]); + $this->callAPISuccess('CustomField', 'delete', ['id' => $this->ids['CustomField']['radio']]); + $this->callAPISuccess('CustomGroup', 'delete', ['id' => $this->ids['CustomGroup']['Custom Group']]); } /**