* - the first creates a new membership, completed contribution, in progress recurring. Check these
* - create another - end date should be extended
*/
- public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment() {
+ public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPaymentYear() {
+ $this->doSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment(array('duration_unit' => 'year', 'recur_frequency_unit' => 'year'));
+ }
+
+ public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPaymentMonth() {
+ $this->doSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment(array('duration_unit' => 'month', 'recur_frequency_unit' => 'month'));
+ }
+
+ public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPaymentDifferentFrequency() {
+ $this->doSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment(array('duration_unit' => 'year', 'recur_frequency_unit' => 'month'));
+ }
+
+ public function doSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment($params = array()) {
$this->params['is_recur'] = 1;
- $this->params['recur_frequency_unit'] = 'month';
- $this->setUpMembershipContributionPage();
+ $this->params['recur_frequency_unit'] = $params['recur_frequency_unit'];
+ $membershipTypeParams['duration_unit'] = $params['duration_unit'];
+ $this->setUpMembershipContributionPage(FALSE, FALSE, $membershipTypeParams);
$dummyPP = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'create_first_success'));
$processor = $dummyPP->getPaymentProcessor();
+ if ($params['recur_frequency_unit'] === $params['duration_unit']) {
+ $expectedMembershipStatus = 1;
+ }
+ else {
+ $expectedMembershipStatus = 5;
+ }
+
$submitParams = array(
'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
'id' => (int) $this->_ids['contribution_page'],
'cvv2' => 123,
'is_recur' => 1,
'frequency_interval' => 1,
- 'frequency_unit' => 'month',
+ 'frequency_unit' => $this->params['recur_frequency_unit'],
);
$this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
$this->assertEquals($membershipPayment['contribution_id'], $contribution['id']);
$membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
$this->assertEquals($membership['contact_id'], $contribution['contact_id']);
- $this->assertEquals(1, $membership['status_id']);
+ $this->assertEquals($expectedMembershipStatus, $membership['status_id']);
$this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id']));
$this->callAPISuccess('line_item', 'getsingle', array('contribution_id' => $contribution['id'], 'entity_id' => $membership['id']));
'contribution_status_id' => 1,
));
$renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
- $this->assertEquals(date('Y-m-d', strtotime('+ 1 year', strtotime($membership['end_date']))), $renewedMembership['end_date']);
+ $this->assertEquals(date('Y-m-d', strtotime('+ 1 ' . $this->params['recur_frequency_unit'], strtotime($membership['end_date']))), $renewedMembership['end_date']);
$recurringContribution = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id']));
$this->assertEquals($processor['payment_instrument_id'], $recurringContribution['payment_instrument_id']);
$this->assertEquals(5, $recurringContribution['contribution_status_id']);
*/
public function testSubmitMembershipComplexNonPriceSetPaymentPaymentProcessorRecurInstantPayment() {
$this->params['is_recur'] = 1;
- $this->params['recur_frequency_unit'] = 'month';
+ $this->params['recur_frequency_unit'] = $membershipTypeParams['duration_unit'] = 'year';
// Add a membership so membership & contribution are not both 1.
$preExistingMembershipID = $this->contactMembershipCreate(array('contact_id' => $this->contactIds[0]));
- $this->setUpMembershipContributionPage();
+ $this->setUpMembershipContributionPage(FALSE, FALSE, $membershipTypeParams);
$dummyPP = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'create_first_success'));
$processor = $dummyPP->getPaymentProcessor();
'cvv2' => 123,
'is_recur' => 1,
'frequency_interval' => 1,
- 'frequency_unit' => 'month',
+ 'frequency_unit' => $this->params['recur_frequency_unit'],
);
$this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
$this->assertEquals($renewContribution['id'], $lines['values'][1]['entity_id']);
$renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
- $this->assertEquals(date('Y-m-d', strtotime('+ 1 year', strtotime($membership['end_date']))), $renewedMembership['end_date']);
+ $this->assertEquals(date('Y-m-d', strtotime('+ 1 ' . $this->params['recur_frequency_unit'], strtotime($membership['end_date']))), $renewedMembership['end_date']);
$recurringContribution = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id']));
$this->assertEquals($processor['payment_instrument_id'], $recurringContribution['payment_instrument_id']);
$this->assertEquals(5, $recurringContribution['contribution_status_id']);
*/
public function testSubmitMembershipComplexPriceSetPaymentPaymentProcessorRecurInstantPayment() {
$this->params['is_recur'] = 1;
- $this->params['recur_frequency_unit'] = 'month';
+ $this->params['recur_frequency_unit'] = $membershipTypeParams['duration_unit'] = 'year';
// Add a membership so membership & contribution are not both 1.
$preExistingMembershipID = $this->contactMembershipCreate(array('contact_id' => $this->contactIds[0]));
$this->createPriceSetWithPage();
'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
'cvv2' => 123,
'frequency_interval' => 1,
- 'frequency_unit' => 'month',
+ 'frequency_unit' => $this->params['recur_frequency_unit'],
);
$this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
$this->assertEquals($renewContribution['id'], $lines['values'][1]['entity_id']);
$renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $preExistingMembershipID + 1));
- $this->assertEquals(date('Y-m-d', strtotime('+ 1 year', strtotime($membership['end_date']))), $renewedMembership['end_date']);
+ $this->assertEquals(date('Y-m-d', strtotime('+ 1 ' . $this->params['recur_frequency_unit'], strtotime($membership['end_date']))), $renewedMembership['end_date']);
}
/**
*/
public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurDelayed() {
$this->params['is_recur'] = 1;
- $this->params['recur_frequency_unit'] = 'month';
+ $this->params['recur_frequency_unit'] = $membershipTypeParams['duration_unit'] = 'year';
$this->setUpMembershipContributionPage();
$dummyPP = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 2));
'cvv2' => 123,
'is_recur' => 1,
'frequency_interval' => 1,
- 'frequency_unit' => 'month',
+ 'frequency_unit' => $this->params['recur_frequency_unit'],
);
$this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL);
'contact_id' => $contribution['contact_id'],
'is_recur' => 1,
'frequency_interval' => 1,
- 'frequency_unit' => 'month',
+ 'frequency_unit' => $this->params['recur_frequency_unit'],
)
);
* Set up membership contribution page.
* @param bool $isSeparatePayment
* @param bool $isRecur
+ * @param array $membershipTypeParams Parameters to pass to membershiptype.create API
*/
- public function setUpMembershipContributionPage($isSeparatePayment = FALSE, $isRecur = FALSE) {
- $this->setUpMembershipBlockPriceSet();
+ public function setUpMembershipContributionPage($isSeparatePayment = FALSE, $isRecur = FALSE, $membershipTypeParams = array()) {
+ $this->setUpMembershipBlockPriceSet($membershipTypeParams);
$this->setupPaymentProcessor();
$this->setUpContributionPage($isRecur);
*
* This function ensures it exists & populates $this->_ids with it's data
*/
- public function setUpMembershipBlockPriceSet() {
+ public function setUpMembershipBlockPriceSet($membershipTypeParams = array()) {
$this->_ids['price_set'][] = $this->callAPISuccess('price_set', 'getvalue', array(
'name' => 'default_membership_type_amount',
'return' => 'id',
));
if (empty($this->_ids['membership_type'])) {
- $this->_ids['membership_type'] = array($this->membershipTypeCreate(array('minimum_fee' => 2)));
+ $membershipTypeParams = array_merge(array(
+ 'minimum_fee' => 2,
+ ), $membershipTypeParams);
+ $this->_ids['membership_type'] = array($this->membershipTypeCreate($membershipTypeParams));
}
$priceField = $this->callAPISuccess('price_field', 'create', array(
'price_set_id' => reset($this->_ids['price_set']),