}
/**
- * Get the idea of the other amount field if the form is configured to offer it.
+ * Get the ID of the other amount field if the form is configured to offer it.
*
* The other amount field is an alternative to the configured radio options,
* specific to this form.
}
/**
- * Get the idea of the other amount field if the form is configured to offer an other amount.
+ * Get the ID of the main amount field if the form is configured to offer an other amount.
*
* The other amount field is an alternative to the configured radio options,
* specific to this form.
*/
protected function assertMailSentContainingString(string $string, int $mailIndex = 0): void {
$mail = $this->form->getMail()[$mailIndex];
- $this->assertStringContainsString($string, $mail['body']);
+ $this->assertStringContainsString(preg_replace('/\s+/', '', $string), preg_replace('/\s+/', '', $mail['body']));
}
/**
], 1);
}
+ /**
+ * Test submit opting for the membership and not the contribution.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testSubmitMembershipBlockNotSeparatePaymentMembershipOnly(): void {
+ $this->contributionPageQuickConfigCreate([], [], FALSE, TRUE, TRUE, TRUE);
+ $this->submitOnlineContributionForm([
+ 'payment_processor_id' => $this->ids['PaymentProcessor']['dummy'],
+ 'price_' . $this->ids['PriceField']['contribution_amount'] => -1,
+ 'price_' . $this->ids['PriceField']['membership_amount'] => $this->ids['PriceFieldValue']['membership_general'],
+ 'id' => $this->getContributionPageID(),
+ ] + $this->getBillingSubmitValues(),
+ $this->getContributionPageID());
+
+ $contribution = $this->callAPISuccess('Contribution', 'getsingle', ['contribution_page_id' => $this->getContributionPageID()]);
+ $membershipPayment = $this->callAPISuccess('MembershipPayment', 'getsingle', ['contribution_id' => $contribution['id']]);
+ $this->callAPISuccessGetSingle('LineItem', ['contribution_id' => $contribution['id'], 'entity_id' => $membershipPayment['id']]);
+ $this->assertMailSentContainingStrings([
+ 'Dear Dave,',
+ 'Membership Information',
+ 'Membership Type General',
+ 'Membership Start Date',
+ 'Membership Expiration',
+ 'Membership Fee',
+ 'Amount $100.00',
+ ]);
+ }
+
}
], 'online');
}
- /**
- * Test submit with a membership block in place.
- */
- public function testSubmitMembershipBlockNotSeparatePayment(): void {
- $this->setUpMembershipContributionPage(FALSE, FALSE, ['minimum_fee' => 0]);
- $submitParams = [
- $this->getPriceFieldLabel('membership') => $this->getPriceFieldValue('general'),
- 'id' => $this->getContributionPageID(),
- 'billing_first_name' => 'Billy',
- 'billing_middle_name' => 'Goat',
- 'billing_last_name' => 'Gruff',
- ];
-
- $this->callAPISuccess('ContributionPage', 'submit', $submitParams);
- $contribution = $this->callAPISuccess('Contribution', 'getsingle', ['contribution_page_id' => $this->getContributionPageID()]);
- $membershipPayment = $this->callAPISuccess('MembershipPayment', 'getsingle', ['contribution_id' => $contribution['id']]);
- $this->callAPISuccessGetSingle('LineItem', ['contribution_id' => $contribution['id'], 'entity_id' => $membershipPayment['id']]);
- }
-
/**
* Test submit with a membership block in place works with renewal.
*