CRM-16692 test
authoreileenmcnaugton <eileen@fuzion.co.nz>
Mon, 10 Aug 2015 01:20:25 +0000 (13:20 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Mon, 10 Aug 2015 01:20:25 +0000 (13:20 +1200)
tests/phpunit/CRM/Member/Form/MembershipTest.php

index 9c92f40b57ea17b32f3412cf89c0940a9971d30b..d788f33da571d9686dd49774ef41a2f0236c928c 100644 (file)
@@ -497,6 +497,45 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase {
     ));
     $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,
+    ));
+
+    // CRM-16992.
+    $this->callAPISuccessGetCount('LineItem', array(
+      'entity_id' => $membership['id'],
+      'entity_table' => 'civicrm_membership',
+      'contribution_id' => $contribution['id'],
+    ), 1);
+  }
+
+  /**
+   * Get a membership form object.
+   *
+   * We need to instantiate the form to run preprocess, which means we have to trick it about the request method.
+   *
+   * @return \CRM_Member_Form_Membership
+   */
+  protected function getForm() {
+    $form = new CRM_Member_Form_Membership();
+    $_SERVER['REQUEST_METHOD'] = 'GET';
+    $form->controller = new CRM_Core_Controller();
+    $form->_bltID = 5;
+    return $form;
+  }
+
+  /**
+   * @return array
+   */
+  protected function getBaseSubmitParams() {
     $params = array(
       'cid' => $this->_individualId,
       'price_set_id' => 0,
@@ -533,38 +572,7 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase {
       'billing_postal_code-5' => '90210',
       'billing_country_id-5' => '1228',
     );
-    $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,
-    ));
-    // Not currently passing.
-    //  $this->callAPISuccessGetCount('LineItem', array(
-    //  'entity_id' => $membership['id'],
-    //  'entity_table' => 'civicrm_membership',
-    //  'contribution_id' => $contribution['id'],
-    //), 1);
-    //
-  }
-
-  /**
-   * Get a membership form object.
-   *
-   * We need to instantiate the form to run preprocess, which means we have to trick it about the request method.
-   *
-   * @return \CRM_Member_Form_Membership
-   */
-  protected function getForm() {
-    $form = new CRM_Member_Form_Membership();
-    $_SERVER['REQUEST_METHOD'] = 'GET';
-    $form->controller = new CRM_Core_Controller();
-    $form->_bltID = 5;
-    return $form;
+    return $params;
   }
 
 }