-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tax fixes in unit test #20390
Merged
Merged
Tax fixes in unit test #20390
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,7 +274,6 @@ public function testGetContributionReturnFunctionality(): void { | |
$params['amount_level'] = 'Unreasonable'; | ||
$params['cancel_reason'] = 'You lose sucker'; | ||
$params['creditnote_id'] = 'sudo rm -rf'; | ||
$params['tax_amount'] = '1'; | ||
$address = $this->callAPISuccess('Address', 'create', [ | ||
'street_address' => 'Knockturn Alley', | ||
'contact_id' => $this->_individualId, | ||
|
@@ -308,6 +307,9 @@ public function testGetContributionReturnFunctionality(): void { | |
$this->assertEquals('bouncer', $contribution['contribution_check_number']); | ||
|
||
$fields = CRM_Contribute_BAO_Contribution::fields(); | ||
// Do not check for tax_amount as this test has not enabled invoicing | ||
// & hence it is not reliable. | ||
unset($fields['tax_amount']); | ||
// Re-add these 2 to the fields to check. They were locked in but the metadata changed so we | ||
// need to specify them. | ||
$fields['address_id'] = $fields['contribution_address_id']; | ||
|
@@ -319,12 +321,12 @@ public function testGetContributionReturnFunctionality(): void { | |
'fee_amount', 'net_amount', 'trxn_id', 'invoice_id', 'currency', 'contribution_cancel_date', 'cancel_reason', | ||
'receipt_date', 'thankyou_date', 'contribution_source', 'amount_level', 'contribution_recur_id', | ||
'is_test', 'is_pay_later', 'contribution_status_id', 'address_id', 'check_number', 'contribution_campaign_id', | ||
'creditnote_id', 'tax_amount', 'revenue_recognition_date', 'decoy', | ||
'creditnote_id', 'revenue_recognition_date', 'decoy', | ||
]; | ||
$missingFields = array_diff($fieldsLockedIn, array_keys($fields)); | ||
// If any of the locked in fields disappear from the $fields array we need to make sure it is still | ||
// covered as the test contract now guarantees them in the return array. | ||
$this->assertEquals($missingFields, [29 => 'decoy'], 'A field which was covered by the test contract has changed.'); | ||
$this->assertEquals([28 => 'decoy'], $missingFields, 'A field which was covered by the test contract has changed.'); | ||
foreach ($fields as $fieldName => $fieldSpec) { | ||
$contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contributionID, 'return' => $fieldName]); | ||
$returnField = $fieldName; | ||
|
@@ -510,8 +512,15 @@ public function testCreateGetFieldsWithCustom(): void { | |
$this->customGroupDelete($idsContact['custom_group_id']); | ||
} | ||
|
||
public function testCreateContributionNoLineItems() { | ||
|
||
/** | ||
* Test creating a contribution without skipLineItems. | ||
* | ||
* @throws \CRM_Core_Exception | ||
*/ | ||
public function testCreateContributionNoLineItems(): void { | ||
// Turn off this validation as this test results in invalid | ||
// financial entities. | ||
$this->isValidateFinancialsOnPostAssert = FALSE; | ||
$params = [ | ||
'contact_id' => $this->_individualId, | ||
'receive_date' => '20120511', | ||
|
@@ -559,7 +568,7 @@ public function testCreateContributionChainedLineItems(): void { | |
'trxn_id' => 12345, | ||
'invoice_id' => 67890, | ||
'source' => 'SSF', | ||
'contribution_status_id' => 1, | ||
'contribution_status_id' => 'Pending', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to pending to create a valid payment flow - does not affect what is being tested (which should never be done in code - use the order api) |
||
'skipLineItem' => 1, | ||
'api.line_item.create' => [ | ||
[ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function (submit()) is used primary by unit tests via the ContributionPage.submit api. AFAIK that api is only used by a barage of tests but there might be some live usages in the ether - I would expect the test cover to be greater than any possible 'wild usage'