return $form;
}
+ /**
+ * Test expired priceset are not returned from buildPriceSet() Function
+ */
+ public function testExpiredPriceSet() {
+ $form = $this->getContributionForm();
+ $priceSetParams1 = array(
+ 'name' => 'priceset',
+ 'title' => 'Priceset with Multiple Terms',
+ 'is_active' => 1,
+ 'extends' => 3,
+ 'financial_type_id' => 2,
+ 'is_quick_config' => 1,
+ 'is_reserved' => 1,
+ );
+ $priceSet = $this->callAPISuccess('price_set', 'create', $priceSetParams1);
+ $form->_priceSetId = $priceSet['id'];
+
+ $form->controller = new CRM_Core_Controller();
+ $form->set('priceSetId', $form->_priceSetId);
+ $params = array(
+ 'price_set_id' => $form->_priceSetId,
+ 'name' => 'testvalidpf',
+ 'label' => 'test valid pf',
+ 'html_type' => 'Radio',
+ 'is_enter_qty' => 1,
+ 'is_active' => 1,
+ );
+ $priceField1 = $this->callAPISuccess('PriceField', 'create', $params);
+
+ //Create expired price field.
+ $params = array(
+ 'price_set_id' => $form->_priceSetId,
+ 'name' => 'testexpiredpf',
+ 'label' => 'test expired pf',
+ 'html_type' => 'Radio',
+ 'is_enter_qty' => 1,
+ 'is_active' => 1,
+ 'expire_on' => date('Y-m-d', strtotime("-1 days")),
+ );
+ $priceField2 = $this->callAPISuccess('PriceField', 'create', $params);
+
+ //Create price options.
+ $membershipOrgId = $this->organizationCreate(NULL);
+ $memtype = $this->membershipTypeCreate(array('member_of_contact_id' => $membershipOrgId));
+ foreach (array($priceField1, $priceField2) as $priceField) {
+ $priceFieldValueParams = array(
+ 'price_field_id' => $priceField['id'],
+ 'name' => 'rye grass',
+ 'membership_type_id' => $memtype,
+ 'label' => 'juicy and healthy',
+ 'amount' => 1,
+ 'membership_num_terms' => 2,
+ 'financial_type_id' => 1,
+ );
+ $this->callAPISuccess('PriceFieldValue', 'create', $priceFieldValueParams);
+ }
+
+ $priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSet['id']));
+ $form->_values['fee'] = $form->_feeBlock = $priceSet['fields'];
+ foreach ($priceSet['fields'] as $pField) {
+ foreach ($pField['options'] as $opId => $opValues) {
+ $membershipTypeIds[$opValues['membership_type_id']] = $opValues['membership_type_id'];
+ }
+ }
+ $form->_membershipTypeValues = CRM_Member_BAO_Membership::buildMembershipTypeValues($form, $membershipTypeIds);
+
+ //This function should not update form priceSet with the expired one.
+ CRM_Price_BAO_PriceSet::buildPriceSet($form);
+
+ $this->assertEquals(count($form->_priceSet['fields']), 1);
+ $field = current($form->_priceSet['fields']);
+ $this->assertEquals($field['name'], 'testvalidpf');
+ }
+
}