Skip to content

Commit

Permalink
Merge pull request #11859 from eileenmcnaughton/import_test
Browse files Browse the repository at this point in the history
[nfc] Add test for thousand separators on import
  • Loading branch information
seamuslee001 authored Mar 22, 2018
2 parents 22b09a4 + 9d8db54 commit 51631b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 2 additions & 8 deletions CRM/Contribute/Import/Parser/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,8 @@ public function import($onDuplicate, &$values) {
}

$params = &$this->getActiveFieldParams();
$formatted = array('version' => 3);

// don't add to recent items, CRM-4399
$formatted['skipRecentView'] = TRUE;

//for date-Formats
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
$formatted = ['version' => 3, 'skipRecentView' => TRUE, 'skipCleanMoney' => FALSE];
$dateType = CRM_Core_Session::singleton()->get('dateTypes');

$customDataType = !empty($params['contact_type']) ? $params['contact_type'] : 'Contribution';
$customFields = CRM_Core_BAO_CustomField::getFields($customDataType);
Expand Down
13 changes: 11 additions & 2 deletions tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ public function setUp() {
*
* In this case primary contact and secondary contact both are identified by external identifier.
*
* @dataProvider getThousandSeparators
*
* @param string $thousandSeparator
*
* @throws \Exception
*/
public function testImportParserWithSoftCreditsByExternalIdentifier() {
public function testImportParserWithSoftCreditsByExternalIdentifier($thousandSeparator) {
$this->setCurrencySeparators($thousandSeparator);
$contact1Params = array(
'first_name' => 'Contact',
'last_name' => 'One',
Expand All @@ -40,7 +45,7 @@ public function testImportParserWithSoftCreditsByExternalIdentifier() {
$contact1Id = $this->individualCreate($contact1Params);
$contact2Id = $this->individualCreate($contact2Params);
$values = array(
"total_amount" => 10,
"total_amount" => $this->formatMoneyInput(1230.99),
"financial_type" => "Donation",
"external_identifier" => "ext-1",
"soft_credit" => "ext-2",
Expand All @@ -53,6 +58,10 @@ public function testImportParserWithSoftCreditsByExternalIdentifier() {
);
$values = array();
$contributionsOfMainContact = CRM_Contribute_BAO_Contribution::retrieve($params, $values, $values);
$this->assertEquals(1230.99, $contributionsOfMainContact->total_amount);
$this->assertEquals(1230.99, $contributionsOfMainContact->net_amount);
$this->assertEquals(0, $contributionsOfMainContact->fee_amount);

$params["contact_id"] = $contact2Id;
$contributionsOfSoftContact = CRM_Contribute_BAO_ContributionSoft::retrieve($params, $values);
$this->assertEquals(1, count($contributionsOfMainContact), 'Contribution not added for primary contact');
Expand Down

0 comments on commit 51631b2

Please sign in to comment.