Skip to content
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

[PHPUnit test only] Adding in assertions re: Line Item and Contribution data-integrity. #12611

Merged
merged 4 commits into from
Aug 5, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tests/phpunit/CRM/Member/Form/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ public function testContributionFormStatusUpdate() {

/**
* CRM-21656: Test the submit function of the membership form if Sale Tax is enabled.
* Check that the tax rate isn't reapplied to line item's unit price and total amount
* Check that the tax rate isn't reapplied to line item's unit price and total amount
*/
public function testLineItemAmountOnSaleTax() {
$this->enableTaxAndInvoicing();
Expand Down Expand Up @@ -1339,8 +1339,18 @@ public function testLineItemAmountOnSaleTax() {
// ensure that the line-item values got unaffected
$lineItem = $this->callAPISuccessGetSingle('LineItem', array('entity_id' => $membership['id'], 'entity_table' => 'civicrm_membership'));
$this->assertEquals(1, $lineItem['qty']);
$this->assertEquals(50.00, $lineItem['unit_price']);
$this->assertEquals(50.00, $lineItem['line_total']);
$this->assertEquals(5.00, $lineItem['tax_amount']); // ensure that tax amount is not changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also check if $lineItem['unit_price'] and $lineItem['line_total'] have not changed on Resubmitting the Edit Contribution form.

// ensure that total_amount at the Contribution level matches line_total + tax_amount at the Line Item Level
$contribution = $this->callAPISuccessGetSingle('Contribution',
array('contribution_id' => 1, 'return' => array('tax_amount', 'total_amount'),
)
);
$this->assertEquals($contribution['total_amount'], $lineItem['line_total'] + $lineItem['tax_amount']);
$this->assertEquals($contribution['tax_amount'], $lineItem['tax_amount']);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the data-integrity part - we must ensure things add up. Since there is only 1 Line Item in this test we don't have to worry about summation over Line Items.

// reset the price options static variable so not leave any dummy data, that might hamper other unit tests
\Civi::$statics['CRM_Price_BAO_PriceField']['priceOptions'] = NULL;
$this->disableTaxAndInvoicing();
Expand Down