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

[NFC] Cleanup on contribution v3 api test #20638

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions Civi/Test/Api3TestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ public function callAPISuccess($entity, $action, $params = [], $checkAgainst = N
* @param array $params
* @param int $count
*
* @throws \CRM_Core_Exception
*
* @return array|int
*/
public function callAPISuccessGetCount($entity, $params, $count = NULL) {
Expand All @@ -197,7 +195,7 @@ public function callAPISuccessGetCount($entity, $params, $count = NULL) {
];
$result = $this->civicrm_api($entity, 'getcount', $params);
if (!is_int($result) || !empty($result['is_error']) || isset($result['values'])) {
throw new \CRM_Core_Exception('Invalid getcount result : ' . print_r($result, TRUE) . " type :" . gettype($result));
$this->fail('Invalid getcount result : ' . print_r($result, TRUE) . ' type :' . gettype($result));
}
if (is_int($count)) {
$this->assertEquals($count, $result, "incorrect count returned from $entity getcount");
Expand Down
17 changes: 13 additions & 4 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2914,7 +2914,10 @@ public function _checkFinancialRecords($params, $context) {
'entity_id' => $params['id'],
'entity_table' => 'civicrm_contribution',
];
$contribution = $this->callAPISuccess('contribution', 'getsingle', ['id' => $params['id']]);
$contribution = $this->callAPISuccess('Contribution', 'getsingle', [
'id' => $params['id'],
'return' => ['total_amount', 'fee_amount', 'net_amount'],
]);
$this->assertEquals($contribution['total_amount'] - $contribution['fee_amount'], $contribution['net_amount']);
if ($context == 'pending') {
$trxn = CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams);
Expand All @@ -2935,7 +2938,7 @@ public function _checkFinancialRecords($params, $context) {
if ($context == 'feeAmount') {
$compareParams['fee_amount'] = 50;
}
elseif ($context == 'online') {
elseif ($context === 'online') {
$compareParams = [
'to_financial_account_id' => 12,
'total_amount' => (float) CRM_Utils_Array::value('total_amount', $params, 100.00),
Expand Down Expand Up @@ -3613,7 +3616,10 @@ protected function validatePayments($payments): void {
* @throws \CRM_Core_Exception
*/
protected function validateAllPayments() {
$payments = $this->callAPISuccess('Payment', 'get', ['options' => ['limit' => 0]])['values'];
$payments = $this->callAPISuccess('Payment', 'get', [
'return' => ['total_amount', 'tax_amount'],
'options' => ['limit' => 0],
])['values'];
$this->validatePayments($payments);
}

Expand All @@ -3625,7 +3631,10 @@ protected function validateAllPayments() {
protected function validateAllContributions(): void {
$contributions = $this->callAPISuccess('Contribution', 'get', ['return' => ['tax_amount', 'total_amount']])['values'];
foreach ($contributions as $contribution) {
$lineItems = $this->callAPISuccess('LineItem', 'get', ['contribution_id' => $contribution['id']])['values'];
$lineItems = $this->callAPISuccess('LineItem', 'get', [
'contribution_id' => $contribution['id'],
'return' => ['tax_amount', 'line_total'],
])['values'];
$total = 0;
$taxTotal = 0;
foreach ($lineItems as $lineItem) {
Expand Down
Loading