Skip to content

Commit

Permalink
Add test for thousand separators on import
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Mar 22, 2018
1 parent bb7aacf commit 9d8db54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 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
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testCancelRecur() {
*/
public function testSupportFinancialTypeChange() {
$contributionRecur = $this->callAPISuccess('contribution_recur', 'create', $this->_params);
$this->callAPISuccess('contribution', 'create', array(
$this->callAPISuccess('Contribution', 'create', array(
'contribution_recur_id' => $contributionRecur['id'],
'total_amount' => '3.00',
'financial_type_id' => 1,
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 9d8db54

Please sign in to comment.