Skip to content

Commit

Permalink
Merge pull request #9909 from eileenmcnaughton/membership
Browse files Browse the repository at this point in the history
Additional unit test, checking membership renewal
  • Loading branch information
eileenmcnaughton authored Feb 28, 2017
2 parents f832e5e + e04004f commit 8994d13
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/phpunit/api/v3/ContributionPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,52 @@ public function testSubmitMembershipBlockNotSeparatePayment() {
$this->callAPISuccessGetSingle('LineItem', array('contribution_id' => $contribution['id'], 'entity_id' => $membershipPayment['id']));
}

/**
* Test submit with a membership block in place works with renewal.
*/
public function testSubmitMembershipBlockNotSeparatePaymentProcessorInstantRenew() {
$this->setUpMembershipContributionPage();
$dummyPP = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1));
$submitParams = array(
'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
'id' => (int) $this->_ids['contribution_page'],
'amount' => 10,
'billing_first_name' => 'Billy',
'billing_middle_name' => 'Goat',
'billing_last_name' => 'Gruff',
'selectMembership' => $this->_ids['membership_type'],
'payment_processor_id' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
'cvv2' => 123,
);

$this->callAPISuccess('contribution_page', 'submit', $submitParams);
$contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page']));
$membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array('contribution_id' => $contribution['id']));
$this->callAPISuccessGetCount('LineItem', array(
'entity_table' => 'civicrm_membership',
'entity_id' => $membershipPayment['id'],
), 1);

$submitParams['contact_id'] = $contribution['contact_id'];

$this->callAPISuccess('contribution_page', 'submit', $submitParams);
$this->callAPISuccessGetCount('LineItem', array(
'entity_table' => 'civicrm_membership',
'entity_id' => $membershipPayment['id'],
), 2);
$membership = $this->callAPISuccessGetSingle('Membership', array(
'id' => $membershipPayment['membership_id'],
'return' => array('end_date', 'join_date', 'start_date'),
));
$this->assertEquals(date('Y-m-d'), $membership['start_date']);
$this->assertEquals(date('Y-m-d'), $membership['join_date']);
$this->assertEquals(date('Y-m-d', strtotime('+ 2 year - 1 day')), $membership['end_date']);
}

/**
* Test submit with a membership block in place.
*/
Expand Down

0 comments on commit 8994d13

Please sign in to comment.