* @group headless
*/
class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase {
+ use CRMTraits_Custom_CustomDataTrait;
protected $_individualId;
protected $_contribution;
'civicrm_relationship',
'civicrm_uf_match',
'civicrm_address',
- ]
+ ], TRUE
);
foreach ($this->ids['contact'] as $contactID) {
$this->callAPISuccess('contact', 'delete', ['id' => $contactID, 'skip_undelete' => TRUE]);
*/
public function testSubmitRecurCompleteInstantWithMail($thousandSeparator) {
$this->setCurrencySeparators($thousandSeparator);
+ // Visibility is 'Public Pages and Listings' in order to try to get to a specific line
+ // of code to ensure it's tested - it might not be a 'real' use case.
+ $this->createCustomGroupWithFieldOfType(['extends' => 'Membership'], 'multi_country', NULL, ['visibility' => 'Public Pages and Listings']);
$form = $this->getForm();
$this->mut = new CiviMailUtils($this, TRUE);
/** @var \CRM_Core_Payment_Dummy $processor */
$form->preProcess();
$form->_contactID = $this->_individualId;
- $form->_mode = 'test';
+ $form->_mode = 'live';
- $form->testSubmit(array_merge($this->getBaseSubmitParams(), ['is_recur' => 1, 'send_receipt' => 1, 'auto_renew' => 1]));
+ $form->testSubmit(array_merge($this->getBaseSubmitParams(), [
+ 'is_recur' => 1,
+ 'send_receipt' => 1,
+ 'auto_renew' => 1,
+ $this->getCustomFieldName('multi_country') => [1006, 1007],
+ ]));
$contributionRecur = $this->callAPISuccessGetSingle('ContributionRecur', ['contact_id' => $this->_individualId]);
$this->assertEquals(1, $contributionRecur['is_email_receipt']);
$this->mut->checkMailLog([
'$ ' . $this->formatMoneyInput(7800.90),
+ 'Country-multi : Angola, Anguilla',
]);
$this->mut->stop();
$this->setCurrencySeparators(',');
* Params for the group to be created.
* @param string $customFieldType
*
- * @param string $identifier
+ * @param string|null $identifier
+ *
+ * @param array $fieldParams
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
- public function createCustomGroupWithFieldOfType($groupParams = [], $customFieldType = 'text', $identifier = NULL) {
- $supported = ['text', 'select', 'date', 'int', 'contact_reference', 'radio'];
+ public function createCustomGroupWithFieldOfType($groupParams = [], $customFieldType = 'text', $identifier = NULL, $fieldParams = []) {
+ $supported = ['text', 'select', 'date', 'int', 'contact_reference', 'radio', 'multi_country'];
if (!in_array($customFieldType, $supported, TRUE)) {
throw new CRM_Core_Exception('we have not yet extracted other custom field types from createCustomFieldsOfAllTypes, Use consistent syntax when you do');
}
$groupParams['name'] = $identifier ?? 'Custom Group';
$this->createCustomGroup($groupParams);
$reference = &$this->ids['CustomField'][$identifier . $customFieldType];
- $fieldParams = ['custom_group_id' => $this->ids['CustomGroup'][$groupParams['name']]];
+ $fieldParams = array_merge($fieldParams, ['custom_group_id' => $this->ids['CustomGroup'][$groupParams['name']]]);
switch ($customFieldType) {
case 'text':
$reference = $this->createTextCustomField($fieldParams)['id'];
$reference = $this->createIntegerRadioCustomField($fieldParams)['id'];
return;
+ case 'multi_country':
+ $reference = $this->createMultiCountryCustomField($fieldParams)['id'];
+ return;
+
}
}