CRM-16993 test to replicate failure
authoreileenmcnaugton <eileen@fuzion.co.nz>
Mon, 10 Aug 2015 02:38:48 +0000 (14:38 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Mon, 10 Aug 2015 03:52:54 +0000 (15:52 +1200)
tests/phpunit/CRM/Member/Form/MembershipTest.php

index d788f33da571d9686dd49774ef41a2f0236c928c..5016f6da5effcc2e1bd3edcb9bd2c7d42249157c 100644 (file)
@@ -517,6 +517,42 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase {
     ), 1);
   }
 
+  /**
+   * Test the submit function of the membership form.
+   */
+  public function testSubmitRecurCompleteInstant() {
+    $form = $this->getForm();
+
+    $processor = Civi\Payment\System::singleton()->getById($this->_paymentProcessorID);
+    $processor->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'kettles boil water'));
+    $this->callAPISuccess('MembershipType', 'create', array(
+      'id' => $this->membershipTypeAnnualFixedID,
+      'duration_unit' => 'month',
+      'duration_interval' => 1,
+      'auto_renew' => TRUE,
+    ));
+    $form->preProcess();
+    $this->createLoggedInUser();
+    $params = $this->getBaseSubmitParams();
+    $form->_mode = 'test';
+
+    $form->submit($params);
+    $membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId));
+    $this->callAPISuccessGetCount('ContributionRecur', array('contact_id' => $this->_individualId), 1);
+
+    $contribution = $this->callAPISuccess('Contribution', 'get', array(
+      'contact_id' => $this->_individualId,
+      'is_test' => TRUE,
+    ));
+
+    $this->callAPISuccessGetCount('LineItem', array(
+      'entity_id' => $membership['id'],
+      'entity_table' => 'civicrm_membership',
+      'contribution_id' => $contribution['id'],
+    ), 1);
+
+  }
+
   /**
    * Get a membership form object.
    *