}
$membershipTypeValues[$memType][$d] = CRM_Utils_Date::processDate($date);
- //$params[$d] = CRM_Utils_Date::processDate( $date );
}
}
}
// add all the additional payment params we need
- $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
- $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
+ $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] =
+ CRM_Core_PseudoConstant::stateProvinceAbbreviation($formValues["billing_state_province_id-{$this->_bltID}"]);
+ $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($formValues["billing_country_id-{$this->_bltID}"]);
- $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
- $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
+ $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($formValues);
+ $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($formValues);
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
parent::setUp();
$this->_individualId = $this->individualCreate();
- $this->_paymentProcessorID = $this->processorCreate();
+ $processor = $this->processorCreate();
+ $this->_paymentProcessorID = $processor->id;
// Insert test data.
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
'civicrm_relationship',
'civicrm_membership_type',
'civicrm_membership',
+ 'civicrm_uf_match',
)
);
$this->callAPISuccess('contact', 'delete', array('id' => 17, 'skip_undelete' => TRUE));
$this->callAPISuccessGetCount('Membership', array('contact_id' => $this->_individualId), 1);
}
+ /**
+ * Test the submit function of the membership form.
+ */
+ public function testSubmitRecur() {
+ $form = $this->getForm();
+
+ $this->callAPISuccess('MembershipType', 'create', array(
+ 'id' => 25,
+ 'duration_unit' => 'month',
+ 'duration_interval' => 1,
+ 'auto_renew' => TRUE,
+ ));
+ $form->preProcess();
+ $this->createLoggedInUser();
+ $params = array(
+ 'cid' => $this->_individualId,
+ 'price_set_id' => 0,
+ 'join_date' => date('m/d/Y', time()),
+ 'start_date' => '',
+ 'end_date' => '',
+ 'campaign_id' => '',
+ // This format reflects the 1 being the organisation & the 25 being the type.
+ 'membership_type_id' => array(1, 25),
+ 'auto_renew' => '1',
+ 'is_recur' => 1,
+ 'max_related' => 0,
+ 'num_terms' => '1',
+ 'source' => '',
+ 'total_amount' => '77.00',
+ 'financial_type_id' => '2', //Member dues, see data.xml
+ 'soft_credit_type_id' => 11,
+ 'soft_credit_contact_id' => '',
+ 'from_email_address' => '"Demonstrators Anonymous" <info@example.org>',
+ 'receipt_text' => 'Thank you text',
+ 'payment_processor_id' => $this->_paymentProcessorID,
+ 'credit_card_number' => '4111111111111111',
+ 'cvv2' => '123',
+ 'credit_card_exp_date' => array(
+ 'M' => '9',
+ 'Y' => '2019', // TODO: Future proof
+ ),
+ 'credit_card_type' => 'Visa',
+ 'billing_first_name' => 'Test',
+ 'billing_middlename' => 'Last',
+ 'billing_street_address-5' => '10 Test St',
+ 'billing_city-5' => 'Test',
+ 'billing_state_province_id-5' => '1003',
+ '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;
+ }
}