$mut->stop();
$mut->clearMessages();
+ $this->validateAllPayments();
}
/**
// pay additional amount
$this->submitPayment(70);
$this->checkResults([30, 70], 2);
+ $this->validateAllPayments();
}
/**
$this->assertEquals(CRM_Core_Session::singleton()->getLoggedInContactID(), $activities[0]['source_contact_id']);
$this->assertEquals([$this->_individualId], $activities[0]['target_contact_id']);
$this->assertEquals([], $activities[0]['assignee_contact_id']);
+ $this->validateAllPayments();
}
/**
]);
$mut->stop();
$mut->clearMessages();
+ $this->validateAllPayments();
}
/**
]);
$mut->stop();
$mut->clearMessages();
+ $this->validateAllPayments();
}
/**
// pay additional amount
$this->submitPayment(30);
$this->checkResults([30, 70], 2);
+ $this->validateAllPayments();
}
/**
$contributionMembership = $this->callAPISuccessGetSingle('Membership', ['id' => $membership['id']]);
$membershipStatus = $this->callAPISuccessGetSingle('MembershipStatus', ['id' => $contributionMembership['status_id']]);
$this->assertEquals('New', $membershipStatus['name']);
+ $this->validateAllPayments();
}
/**
$this->submitPayment(10);
$this->checkResults([40, 20, 30, 10], 4);
+ $this->validateAllPayments();
}
/**
$this->submitPayment(10, 'live');
$this->checkResults([50, 20, 20, 10], 4);
+ $this->validateAllPayments();
}
/**
return $orderParams;
}
+ /**
+ * @param $payments
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function validatePayments($payments) {
+ foreach ($payments as $payment) {
+ $items = $this->callAPISuccess('EntityFinancialTrxn', 'get', [
+ 'financial_trxn_id' => $payment['id'],
+ 'entity_table' => 'civicrm_financial_item',
+ 'return' => ['amount'],
+ ])['values'];
+ $itemTotal = 0;
+ foreach ($items as $item) {
+ $itemTotal += $item['amount'];
+ }
+ $this->assertEquals($payment['total_amount'], $itemTotal);
+ }
+ }
+
+ /**
+ * Validate all created payments.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function validateAllPayments() {
+ $payments = $this->callAPISuccess('Payment', 'get', ['options' => ['limit' => 0]])['values'];
+ $this->validatePayments($payments);
+ }
+
}
protected $_financialTypeId = 1;
- protected $_apiversion;
-
- public $debug = 0;
-
/**
* Setup function.
+ *
+ * @throws \CRM_Core_Exception
*/
public function setUp() {
parent::setUp();
/**
* Test Get Payment api.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testGetPayment() {
$p = [
$this->callAPISuccess('Contribution', 'Delete', [
'id' => $contribution['id'],
]);
+ $this->validateAllPayments();
}
/**
* Retrieve Payment using trxn_id.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testGetPaymentWithTrxnID() {
$this->_individualId2 = $this->individualCreate();
],
];
$this->checkPaymentResult($payment, $expectedResult);
+ $this->validateAllPayments();
}
/**
* Test email receipt for partial payment.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testPaymentEmailReceipt() {
$mut = new CiviMailUtils($this);
]);
$mut->stop();
$mut->clearMessages();
+ $this->validateAllPayments();
}
/**
]);
$mut->stop();
$mut->clearMessages();
+ $this->validateAllPayments();
}
/**
* @dataProvider getThousandSeparators
*
* @param string $thousandSeparator
+ *
+ * @throws \CRM_Core_Exception
*/
public function testRefundEmailReceipt($thousandSeparator) {
$this->setCurrencySeparators($thousandSeparator);
]);
$mut->stop();
$mut->clearMessages();
+ $this->validateAllPayments();
}
/**
'order_id' => $order['id'],
'total_amount' => 50,
]);
+ $this->validateAllPayments();
}
/**
$this->callAPISuccess('Contribution', 'Delete', [
'id' => $contribution['id'],
]);
+ $this->validateAllPayments();
}
/**
$participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $paymentParticipant);
$participant = $this->callAPISuccess('participant', 'get', ['id' => $participantPayment['participant_id']]);
$this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Registered');
- $this->callAPISuccess('Contribution', 'Delete', [
- 'id' => $contribution['id'],
- ]);
+ $this->validateAllPayments();
}
/**
$this->callAPISuccess('Contribution', 'Delete', [
'id' => $contribution['id'],
]);
+ $this->validateAllPayments();
}
/**
* Test delete payment api
+ *
+ * @throws \CRM_Core_Exception
*/
public function testDeletePayment() {
CRM_Core_Config::singleton()->userPermissionClass->permissions = ['administer CiviCRM', 'access CiviContribute'];
$this->callAPISuccess('Contribution', 'Delete', [
'id' => $contribution['id'],
]);
+ $this->validateAllPayments();
}
/**
* Test create payment api for paylater contribution
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCreatePaymentPayLater() {
$this->createLoggedInUser();
$this->callAPISuccess('Contribution', 'Delete', [
'id' => $contribution['id'],
]);
+ $this->validateAllPayments();
}
/**
* Test create payment api for pay later contribution with partial payment.
*
* https://lab.civicrm.org/dev/financial/issues/69
+ * @throws \CRM_Core_Exception
*/
public function testCreatePaymentIncompletePaymentPartialPayment() {
$contributionParams = [
]);
$payments = $this->callAPISuccess('Payment', 'get', ['contribution_id' => $contribution['id']])['values'];
$this->assertCount(1, $payments);
+ $this->validateAllPayments();
}
/**
]);
$this->callAPISuccess('OptionValue', 'get', ['name' => 'Completed', 'option_group_id' => 'contribution_status', 'api.OptionValue.create' => ['label' => 'Completed']]);
$this->callAPISuccessGetCount('Activity', ['target_contact_id' => $this->_individualId, 'activity_type_id' => 'Payment'], 2);
+ $this->validateAllPayments();
}
/**
'loc_block_id' => $location['id'],
'is_show_location' => TRUE,
]);
+ $this->validateAllPayments();
}
/**
]);
$this->assertEquals($eft['values'][$eft['id']]['amount'], $amount);
+ $this->validateAllPayments();
}
}