*
* @throws \CRM_Core_Exception
*/
- public function testSubmitNewBillingNameDoNotOverwrite() {
+ public function testSubmitNewBillingNameDoNotOverwrite(): void {
$this->setUpContributionPage();
$contact = $this->callAPISuccess('Contact', 'create', [
'contact_type' => 'Individual',
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessorNow() {
+ public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessorNow(): void {
// Need to work on valid financials on this test.
$this->isValidateFinancialsOnPostAssert = FALSE;
$mut = new CiviMailUtils($this, TRUE);
'cvv2' => 123,
];
- $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
+ $this->callAPIAndDocument('ContributionPage', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
$contributions = $this->callAPISuccess('contribution', 'get', [
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_status_id' => 1,
]);
$this->assertCount(2, $contributions['values']);
$membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', []);
- $this->assertTrue(in_array($membershipPayment['contribution_id'], array_keys($contributions['values'])));
+ $this->assertArrayHasKey($membershipPayment['contribution_id'], $contributions['values']);
$membership = $this->callAPISuccessGetSingle('membership', ['id' => $membershipPayment['membership_id']]);
$this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']);
$lineItem = $this->callAPISuccessGetSingle('LineItem', ['entity_table' => 'civicrm_membership']);
- $this->assertEquals($lineItem['entity_id'], $membership['id']);
- $this->assertEquals($lineItem['contribution_id'], $membershipPayment['contribution_id']);
- $this->assertEquals($lineItem['qty'], 1);
- $this->assertEquals($lineItem['unit_price'], 2);
- $this->assertEquals($lineItem['line_total'], 2);
+ $this->assertEquals($membership['id'], $lineItem['entity_id']);
+ $this->assertEquals($membershipPayment['contribution_id'], $lineItem['contribution_id']);
+ $this->assertEquals(1, $lineItem['qty']);
+ $this->assertEquals(2, $lineItem['unit_price']);
+ $this->assertEquals(2, $lineItem['line_total']);
foreach ($contributions['values'] as $contribution) {
$this->assertEquals(.72, $contribution['fee_amount']);
$this->assertEquals($contribution['total_amount'] - .72, $contribution['net_amount']);
*
* @dataProvider getThousandSeparators
*/
- public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessorNowChargesCorrectAmounts($thousandSeparator) {
+ public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessorNowChargesCorrectAmounts($thousandSeparator): void {
$this->setCurrencySeparators($thousandSeparator);
$this->setUpMembershipContributionPage(TRUE);
$processor = Civi\Payment\System::singleton()->getById($this->_paymentProcessor['id']);
$this->hookClass->setHook('civicrm_alterPaymentProcessorParams', [$this, 'hook_civicrm_alterPaymentProcessorParams']);
$this->callAPISuccess('ContributionPage', 'submit', $submitParams);
- $this->callAPISuccess('contribution', 'get', [
+ $this->callAPISuccess('Contribution', 'get', [
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_status_id' => 1,
]);
$contribution_ids = [];
$found_membership_amount = $found_contribution_amount = FALSE;
foreach ($result['values'] as $value) {
- list($junk, $json) = explode("$test_uniq:", $value['message']);
+ [$junk, $json] = explode("$test_uniq:", $value['message']);
$logged_contribution = json_decode($json, TRUE);
$contribution_ids[] = $logged_contribution['contributionID'];
if (!empty($logged_contribution['total_amount'])) {
*
* @throws \CRM_Core_Exception
*/
- public function setUpMembershipContributionPage($isSeparatePayment = FALSE, $isRecur = FALSE, $membershipTypeParams = []) {
+ public function setUpMembershipContributionPage($isSeparatePayment = FALSE, $isRecur = FALSE, $membershipTypeParams = []): void {
$this->setUpMembershipBlockPriceSet($membershipTypeParams);
$this->setupPaymentProcessor();
$this->setUpContributionPage($isRecur);
//$this->assertEquals(12, $contribution['values'][1]['api.ContributionRecur.getsingle']['frequency_interval']);
}
- public static function setUpBeforeClass() {
- // put stuff here that should happen before all tests in this unit
- }
-
/**
* Create a payment processor instance.
*
/**
* Test Tax Amount is calculated properly when using PriceSet with Field Type = Text/Numeric Quantity
*
+ * The created contribution has 3 line items
+ *
+ * |qty | unit_price| line_total| tax |total including tax|
+ * | 1 | 10 | 10 | 0 | 10 |
+ * | 180 | 16.95 | 3051 |305.1 | 3356.1|
+ * | 110 | 2.95 | 324.5 | 32.45 | 356.95|
+ *
+ * Contribution total = 3723.05
+ * made up of tax 337.55
+ * non tax 3385.5
* @param string $thousandSeparator
* punctuation used to refer to thousands.
*
* @dataProvider getThousandSeparators
* @throws \CRM_Core_Exception
*/
- public function testSubmitContributionPageWithPriceSetQuantity($thousandSeparator) {
+ public function testSubmitContributionPageWithPriceSetQuantity(string $thousandSeparator): void {
$this->setCurrencySeparators($thousandSeparator);
$this->_priceSetParams['is_quick_config'] = 0;
$this->enableTaxAndInvoicing();
'html_type' => 'Text',
]);
- $this->callAPISuccess('price_field_value', 'create', [
+ $this->callAPISuccess('PriceFieldValue', 'create', [
'price_set_id' => $priceSetID,
'price_field_id' => $priceField['id'],
'label' => 'Printing Rights',
// Set quantity for our test
$submitParams['price_' . $priceFieldId] = 180;
- $priceField = $this->callAPISuccess('price_field', 'create', [
+ $priceField = $this->callAPISuccess('PriceField', 'create', [
'price_set_id' => $priceSetID,
'label' => 'Another Line Item',
'html_type' => 'Text',
$this->callAPISuccess('ContributionPage', 'submit', $submitParams);
$this->validateAllContributions();
- $contribution = $this->callAPISuccessGetSingle('contribution', [
+ $contribution = $this->callAPISuccessGetSingle('Contribution', [
'contribution_page_id' => $this->_ids['contribution_page'],
]);