*/
protected $_ids = [];
-
public $DBResetRequired = TRUE;
+ /**
+ * Setup for test.
+ *
+ * @throws \CRM_Core_Exception
+ */
public function setUp() {
parent::setUp();
$this->contactIds[] = $this->individualCreate();
$this->params = [
- 'title' => "Test Contribution Page",
+ 'title' => 'Test Contribution Page',
'financial_type_id' => 1,
'currency' => 'NZD',
'goal_amount' => $this->testAmount,
];
}
+ /**
+ * Tear down after test.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
+ */
public function tearDown() {
foreach ($this->contactIds as $id) {
$this->callAPISuccess('contact', 'delete', ['id' => $id]);
}
/**
+ * Test creating a contribution page.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testCreateContributionPage($version) {
$this->_apiversion = $version;
}
/**
+ * Test getting a contribution page.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testGetBasicContributionPage($version) {
$this->_apiversion = $version;
$this->assertEquals(1, $getResult['count']);
}
+ /**
+ * Test get with amount as a parameter.
+ *
+ * @throws \CRM_Core_Exception
+ */
public function testGetContributionPageByAmount() {
$createResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
$this->id = $createResult['id'];
}
/**
+ * Test page deletion.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testDeleteContributionPage($version) {
$this->_apiversion = $version;
$this->assertEquals(0, $checkDeleted['count']);
}
+ /**
+ * Test getfields function.
+ *
+ * @throws \CRM_Core_Exception
+ */
public function testGetFieldsContributionPage() {
$result = $this->callAPISuccess($this->_entity, 'getfields', ['action' => 'create']);
$this->assertEquals(12, $result['values']['start_date']['type']);
/**
* Test form submission with basic price set.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmit() {
$this->setUpContributionPage();
/**
* Test form submission with billing first & last name where the contact does NOT
* otherwise have one.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitNewBillingNameData() {
$this->setUpContributionPage();
* Test process with instant payment when more than one configured for the page.
*
* CRM-16923
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
public function testSubmitRecurMultiProcessorInstantPayment() {
$this->setUpContributionPage();
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockNotSeparatePayment() {
$this->setUpMembershipContributionPage();
'billing_middle_name' => 'Goat',
'billing_last_name' => 'Gruff',
'selectMembership' => $this->_ids['membership_type'],
-
];
- $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
+ $this->callAPIAndDocument('ContributionPage', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
$contribution = $this->callAPISuccess('contribution', 'getsingle', ['contribution_page_id' => $this->_ids['contribution_page']]);
$membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', ['contribution_id' => $contribution['id']]);
$this->callAPISuccessGetSingle('LineItem', ['contribution_id' => $contribution['id'], 'entity_id' => $membershipPayment['id']]);
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockNotSeparatePaymentWithEmail() {
$mut = new CiviMailUtils($this, TRUE);
/**
* Test submit with a membership block in place.
+ *
+ * @throws \Exception
*/
public function testSubmitMembershipBlockNotSeparatePaymentZeroDollarsWithEmail() {
$mut = new CiviMailUtils($this, TRUE);
/**
* Test submit with a pay later abnd check line item in mails.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockIsSeparatePaymentPayLaterWithEmail() {
$mut = new CiviMailUtils($this, TRUE);
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockIsSeparatePayment() {
$this->setUpMembershipContributionPage(TRUE);
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockIsSeparatePaymentWithPayLater() {
$this->setUpMembershipContributionPage(TRUE);
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockIsSeparatePaymentWithEmail() {
$mut = new CiviMailUtils($this, TRUE);
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockIsSeparatePaymentZeroDollarsPayLaterWithEmail() {
$mut = new CiviMailUtils($this, TRUE);
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipBlockTwoTypesIsSeparatePayment() {
$this->_ids['membership_type'] = [$this->membershipTypeCreate(['minimum_fee' => 6])];
* @param string $thousandSeparator
* punctuation used to refer to thousands.
*
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
+ *
* @dataProvider getThousandSeparators
*/
public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessorNowChargesCorrectAmounts($thousandSeparator) {
// set custom hook
$this->hookClass->setHook('civicrm_alterPaymentProcessorParams', [$this, 'hook_civicrm_alterPaymentProcessorParams']);
- $this->callAPISuccess('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
- $contributions = $this->callAPISuccess('contribution', 'get', [
+ $this->callAPISuccess('ContributionPage', 'submit', $submitParams);
+ $this->callAPISuccess('contribution', 'get', [
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_status_id' => 1,
]);
* Test that when a transaction fails the pending contribution remains.
*
* An activity should also be created. CRM-16417.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitPaymentProcessorFailure() {
$this->setUpContributionPage();
* processor (IATS style - denoted by returning trxn_id)
* - the first creates a new membership, completed contribution, in progress recurring. Check these
* - create another - end date should be extended
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPaymentYear() {
$this->doSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment(['duration_unit' => 'year', 'recur_frequency_unit' => 'year']);
* @param array $params
*
* @throws \CRM_Core_Exception
- * @throws \Exception
*/
public function doSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment($params = []) {
$this->params['is_recur'] = 1;
* processor (IATS style - denoted by returning trxn_id)
* - the first creates a new membership, completed contribution, in progress recurring. Check these
* - create another - end date should be extended
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipComplexNonPriceSetPaymentPaymentProcessorRecurInstantPayment() {
$this->params['is_recur'] = 1;
* processor (IATS style - denoted by returning trxn_id)
* - the first creates a new membership, completed contribution, in progress recurring. Check these
* - create another - end date should be extended
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipComplexPriceSetPaymentPaymentProcessorRecurInstantPayment() {
$this->params['is_recur'] = 1;
/**
* Extend the price set with a second organisation's membership.
+ *
+ * @throws \CRM_Core_Exception
*/
public function addSecondOrganizationMembershipToPriceSet() {
$organization2ID = $this->organizationCreate();
* processor (IATS style - denoted by returning trxn_id)
* - the first creates a new membership, completed contribution, in progress recurring. Check these
* - create another - end date should be extended
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipPriceSetPaymentPaymentProcessorSeparatePaymentRecurInstantPayment() {
'frequency_unit' => 'month',
];
- $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
+ $this->callAPIAndDocument('ContributionPage', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
$contribution = $this->callAPISuccess('contribution', 'get', [
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_status_id' => 1,
* - the first creates a pending membership, pending contribution, penging recurring. Check these
* - complete the transaction
* - create another - end date should NOT be extended
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurDelayed() {
$this->params['is_recur'] = 1;
/**
* Test non-recur contribution with membership payment
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMembershipIsSeparatePaymentNotRecur() {
//Create recur contribution page.
/**
* Set up membership contribution page.
+ *
* @param bool $isSeparatePayment
* @param bool $isRecur
* @param array $membershipTypeParams Parameters to pass to membershiptype.create API
+ *
+ * @throws \CRM_Core_Exception
*/
public function setUpMembershipContributionPage($isSeparatePayment = FALSE, $isRecur = FALSE, $membershipTypeParams = []) {
$this->setUpMembershipBlockPriceSet($membershipTypeParams);
* The default data set does not include a complete default membership price set - not quite sure why.
*
* This function ensures it exists & populates $this->_ids with it's data
+ *
+ * @throws \CRM_Core_Exception
*/
public function setUpMembershipBlockPriceSet($membershipTypeParams = []) {
$this->_ids['price_set'][] = $this->callAPISuccess('price_set', 'getvalue', [
/**
* Add text field other amount to the price set.
+ *
+ * @throws \CRM_Core_Exception
*/
public function addOtherAmountFieldToMembershipPriceSet() {
$this->_ids['price_field']['other_amount'] = $this->callAPISuccess('price_field', 'create', [
/**
* Help function to set up contribution page with some defaults.
+ *
* @param bool $isRecur
+ *
+ * @throws \CRM_Core_Exception
*/
public function setUpContributionPage($isRecur = FALSE) {
if ($isRecur) {
/**
* Helper function to set up contribution page which can be used to purchase a
* membership type for different intervals.
+ *
+ * @throws \CRM_Core_Exception
*/
public function setUpMultiIntervalMembershipContributionPage() {
$this->setupPaymentProcessor();
'duration_unit' => 'month',
]);
- $priceSet = civicrm_api3('PriceSet', 'create', [
+ $priceSet = $this->callAPISuccess('PriceSet', 'create', [
'is_quick_config' => 0,
'extends' => 'CiviMember',
'financial_type_id' => 'Member Dues',
/**
* Test submit with a membership block in place.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitMultiIntervalMembershipContributionPage() {
$this->setUpMultiIntervalMembershipContributionPage();
// put stuff here that should happen before all tests in this unit
}
- /**
- * @throws \Exception
- */
- public static function tearDownAfterClass() {
- $tablesToTruncate = [
- 'civicrm_contact',
- 'civicrm_financial_type',
- 'civicrm_contribution',
- 'civicrm_contribution_page',
- ];
- $unitTest = new CiviUnitTestCase();
- $unitTest->quickCleanup($tablesToTruncate);
- }
-
/**
* Create a payment processor instance.
+ *
+ * @throws \CRM_Core_Exception
*/
protected function setupPaymentProcessor() {
$this->params['payment_processor_id'] = $this->_ids['payment_processor'] = $this->paymentProcessorCreate([
* Test submit recurring pledge.
*
* - we process 1 pledge with a future start date. A recur contribution and the pledge should be created with first payment date in the future.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitPledgePaymentPaymentProcessorRecurFuturePayment() {
$this->params['adjust_recur_start_date'] = TRUE;
* Test submit pledge payment.
*
* - test submitting a pledge payment using contribution form.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitPledgePayment() {
$this->testSubmitPledgePaymentPaymentProcessorRecurFuturePayment();
* punctuation used to refer to thousands.
*
* @dataProvider getThousandSeparators
+ * @throws \CRM_Core_Exception
*/
public function testSubmitContributionPageWithPriceSet($thousandSeparator) {
$this->setCurrencySeparators($thousandSeparator);
/**
* Function to add additional price fields to priceset.
+ *
* @param array $params
+ *
+ * @throws \CRM_Core_Exception
*/
public function addPriceFields(&$params) {
$priceSetID = reset($this->_ids['price_set']);
* punctuation used to refer to thousands.
*
* @dataProvider getThousandSeparators
+ * @throws \CRM_Core_Exception
*/
public function testSubmitContributionPageWithPriceSetQuantity($thousandSeparator) {
$this->setCurrencySeparators($thousandSeparator);