/**
* Initial test of submit function.
- *
- * @throws \Exception
*/
public function testSubmit(): void {
$event = $this->eventCreate();
$mut = new CiviMailUtils($this, TRUE);
- CRM_Event_Form_Registration_Confirm::testSubmit([
- 'id' => $event['id'],
- 'contributeMode' => 'direct',
- 'registerByID' => $this->createLoggedInUser(),
- 'params' => [
- [
- 'qfKey' => 'e6eb2903eae63d4c5c6cc70bfdda8741_2801',
- 'entryURL' => 'http://dmaster.local/civicrm/event/register?reset=1&id=3',
- 'first_name' => 'k',
- 'last_name' => 'p',
- 'email-Primary' => 'demo@example.com',
- 'hidden_processor' => '1',
- 'credit_card_number' => '4111111111111111',
- 'cvv2' => '123',
- 'credit_card_exp_date' => [
- 'M' => '1',
- 'Y' => '2019',
- ],
- 'credit_card_type' => 'Visa',
- 'billing_first_name' => 'p',
- 'billing_middle_name' => '',
- 'billing_last_name' => 'p',
- 'billing_street_address-5' => 'p',
- 'billing_city-5' => 'p',
- 'billing_state_province_id-5' => '1061',
- 'billing_postal_code-5' => '7',
- 'billing_country_id-5' => '1228',
- 'priceSetId' => '6',
- 'price_7' => [
- 13 => 1,
- ],
- 'payment_processor_id' => '1',
- 'bypass_payment' => '',
- 'MAX_FILE_SIZE' => '33554432',
- 'is_primary' => 1,
- 'is_pay_later' => 0,
- 'campaign_id' => NULL,
- 'defaultRole' => 1,
- 'participant_role_id' => '1',
- 'currencyID' => 'USD',
- 'amount_level' => '\ 1Tiny-tots (ages 5-8) - 1\ 1',
- 'amount' => '800.00',
- 'tax_amount' => NULL,
- 'year' => '2019',
- 'month' => '1',
- 'ip_address' => '127.0.0.1',
- 'invoiceID' => '57adc34957a29171948e8643ce906332',
- 'button' => '_qf_Register_upload',
- 'billing_state_province-5' => 'AP',
- 'billing_country-5' => 'US',
- ],
+ $this->submitForm($event['id'], [
+ 'first_name' => 'k',
+ 'last_name' => 'p',
+ 'email-Primary' => 'demo@example.com',
+ 'hidden_processor' => '1',
+ 'credit_card_number' => '4111111111111111',
+ 'cvv2' => '123',
+ 'credit_card_exp_date' => [
+ 'M' => '1',
+ 'Y' => '2019',
+ ],
+ 'credit_card_type' => 'Visa',
+ 'billing_first_name' => 'p',
+ 'billing_middle_name' => '',
+ 'billing_last_name' => 'p',
+ 'billing_street_address-5' => 'p',
+ 'billing_city-5' => 'p',
+ 'billing_state_province_id-5' => '1061',
+ 'billing_postal_code-5' => '7',
+ 'billing_country_id-5' => '1228',
+ 'priceSetId' => '6',
+ 'price_7' => [
+ 13 => 1,
],
+ 'payment_processor_id' => '1',
+ 'bypass_payment' => '',
+ 'is_primary' => 1,
+ 'is_pay_later' => 0,
+ 'campaign_id' => NULL,
+ 'defaultRole' => 1,
+ 'participant_role_id' => '1',
+ 'currencyID' => 'USD',
+ 'amount_level' => '\ 1Tiny-tots (ages 5-8) - 1\ 1',
+ 'amount' => '800.00',
+ 'tax_amount' => NULL,
+ 'year' => '2019',
+ 'month' => '1',
+ 'ip_address' => '127.0.0.1',
+ 'invoiceID' => '57adc34957a29171948e8643ce906332',
+ 'button' => '_qf_Register_upload',
+ 'billing_state_province-5' => 'AP',
+ 'billing_country-5' => 'US',
]);
$mut->checkMailLog([
'amount' => '1.67',
], $entityFinancialTrxns[2], ['id', 'entity_id']);
$mut->checkMailLog([
- 'Event Information and Location', 'Registration Confirmation - Annual CiviCRM meet',
+ 'Event Information and Location',
+ 'Registration Confirmation - Annual CiviCRM meet',
'Expires: January ' . (date('Y') + 1),
'Visa',
'************1111',
/**
* Test online registration for event with no price options selected as per CRM-19964.
*/
- public function testOnlineRegNoPrice() {
+ public function testOnlineRegNoPrice(): void {
$this->processorCreate(['is_default' => TRUE, 'user_name' => 'Test', 'is_test' => FALSE]);
$paymentProcessorID = $this->processorCreate(['is_default' => TRUE, 'user_name' => 'Test', 'is_test' => TRUE]);
$params = [
]
);
// Create online event registration.
- CRM_Event_Form_Registration_Confirm::testSubmit([
- 'id' => $event['id'],
- 'contributeMode' => 'direct',
- 'registerByID' => $this->createLoggedInUser(),
- 'totalAmount' => 0,
- 'params' => [
- [
- 'qfKey' => 'e6eb2903eae63d4c5c6cc70bfdda8741_2801',
- 'entryURL' => "http://dmaster.local/civicrm/event/register?reset=1&id={$event['id']}",
- 'first_name' => 'Bruce',
- 'last_name' => 'Wayne',
- 'email-Primary' => 'bruce@gotham.com',
- 'price_' . $priceField['id'] => '',
- 'priceSetId' => $priceField['values'][$priceField['id']]['price_set_id'],
- 'payment_processor_id' => $paymentProcessorID,
- 'amount' => 0,
- 'bypass_payment' => '',
- 'MAX_FILE_SIZE' => '33554432',
- 'is_primary' => 1,
- 'is_pay_later' => 0,
- 'campaign_id' => NULL,
- 'defaultRole' => 1,
- 'participant_role_id' => '1',
- 'tax_amount' => NULL,
- 'ip_address' => '127.0.0.1',
- 'invoiceID' => '57adc34957a29171948e8643ce906332',
- 'button' => '_qf_Register_upload',
- ],
- ],
- ]);
+ $this->submitForm(
+ $event['id'],
+ [
+ 'first_name' => 'Bruce',
+ 'last_name' => 'Wayne',
+ 'email-Primary' => 'bruce@gotham.com',
+ 'price_' . $priceField['id'] => '',
+ 'priceSetId' => $priceField['values'][$priceField['id']]['price_set_id'],
+ 'payment_processor_id' => $paymentProcessorID,
+ 'amount' => 0,
+ 'amount_level' => '',
+ 'bypass_payment' => '',
+ 'is_primary' => 1,
+ 'is_pay_later' => 0,
+ 'campaign_id' => NULL,
+ 'defaultRole' => 1,
+ 'participant_role_id' => '1',
+ 'tax_amount' => NULL,
+ 'ip_address' => '127.0.0.1',
+ 'invoiceID' => '57adc34957a29171948e8643ce906332',
+ 'button' => '_qf_Register_upload',
+ ]
+ );
$contribution = $this->callAPISuccess('Contribution', 'get', ['invoice_id' => '57adc34957a29171948e8643ce906332']);
$this->assertEquals($contribution['count'], '0', "Contribution should not be created for zero fee event registration when no price field selected.");
}
$event = $this->eventCreate();
$this->createJoinedProfile(['entity_table' => 'civicrm_event', 'entity_id' => $event['id']]);
+ $_REQUEST['id'] = $event['id'];
/* @var \CRM_Event_Form_Registration_Confirm $form */
$form = $this->getFormObject('CRM_Event_Form_Registration_Confirm');
$form->set('params', [[]]);
- $form->set('id', $event['id']);
$form->set('values', [
'event' => $event['values'][$event['id']],
'location' => [],
$contact_id = $this->createLoggedInUser();
}
$mut = new CiviMailUtils($this, TRUE);
- CRM_Event_Form_Registration_Confirm::testSubmit([
- 'id' => $event['id'],
- 'contributeMode' => 'direct',
- 'registerByID' => $contact_id,
- 'custom_pre_id' => $event['custom_pre_id'],
- 'params' => [
- [
- 'qfKey' => 'e6eb2903eae63d4c5c6cc70bfdda8741_2801',
- 'entryURL' => 'http://dmaster.local/civicrm/event/register?reset=1&id=3',
- 'first_name' => 'k',
- 'last_name' => 'p',
- 'email-Primary' => 'demo@example.com',
- 'hidden_processor' => '1',
- 'credit_card_number' => '4111111111111111',
- 'cvv2' => '123',
- 'credit_card_exp_date' => [
- 'M' => '1',
- 'Y' => '2019',
- ],
- 'credit_card_type' => 'Visa',
- 'billing_first_name' => 'p',
- 'billing_middle_name' => '',
- 'billing_last_name' => 'p',
- 'billing_street_address-5' => 'p',
- 'billing_city-5' => 'p',
- 'billing_state_province_id-5' => '1061',
- 'billing_postal_code-5' => '7',
- 'billing_country_id-5' => '1228',
- 'priceSetId' => '6',
- 'price_7' => [
- 13 => 1,
- ],
- 'payment_processor_id' => '1',
- 'bypass_payment' => '',
- 'MAX_FILE_SIZE' => '33554432',
- 'is_primary' => 1,
- 'is_pay_later' => 0,
- 'campaign_id' => NULL,
- 'defaultRole' => 1,
- 'participant_role_id' => '1',
- 'currencyID' => 'USD',
- 'amount_level' => '\ 1Tiny-tots (ages 5-8) - 1\ 1',
- 'amount' => '800.00',
- 'tax_amount' => NULL,
- 'year' => '2019',
- 'month' => '1',
- 'ip_address' => '127.0.0.1',
- 'invoiceID' => '57adc34957a29171948e8643ce906332',
- 'button' => '_qf_Register_upload',
- 'billing_state_province-5' => 'AP',
- 'billing_country-5' => 'US',
- 'note' => $event['note'],
- ],
+ $this->submitForm($event['id'], [
+ 'first_name' => 'k',
+ 'last_name' => 'p',
+ 'email-Primary' => 'demo@example.com',
+ 'hidden_processor' => '1',
+ 'credit_card_number' => '4111111111111111',
+ 'cvv2' => '123',
+ 'credit_card_exp_date' => [
+ 'M' => '1',
+ 'Y' => '2019',
],
+ 'credit_card_type' => 'Visa',
+ 'billing_first_name' => 'p',
+ 'billing_middle_name' => '',
+ 'billing_last_name' => 'p',
+ 'billing_street_address-5' => 'p',
+ 'billing_city-5' => 'p',
+ 'billing_state_province_id-5' => '1061',
+ 'billing_postal_code-5' => '7',
+ 'billing_country_id-5' => '1228',
+ 'priceSetId' => '6',
+ 'price_7' => [
+ 13 => 1,
+ ],
+ 'payment_processor_id' => '1',
+ 'bypass_payment' => '',
+ 'is_primary' => 1,
+ 'is_pay_later' => 0,
+ 'campaign_id' => NULL,
+ 'defaultRole' => 1,
+ 'participant_role_id' => '1',
+ 'currencyID' => 'USD',
+ 'amount_level' => '\ 1Tiny-tots (ages 5-8) - 1\ 1',
+ 'amount' => '800.00',
+ 'tax_amount' => NULL,
+ 'year' => '2019',
+ 'month' => '1',
+ 'ip_address' => '127.0.0.1',
+ 'invoiceID' => '57adc34957a29171948e8643ce906332',
+ 'button' => '_qf_Register_upload',
+ 'billing_state_province-5' => 'AP',
+ 'billing_country-5' => 'US',
+ 'note' => $event['note'],
]);
$participant = $this->callAPISuccessGetSingle('Participant', []);
$mut->checkMailLog(['Comment: ' . $event['note'] . chr(0x0A)]);
$this->uf_field_add($this->ids["UFGroup"]["our profile"], 'note', 'Contact', 'Comment');
}
+ $_REQUEST['id'] = $event['id'];
/* @var \CRM_Event_Form_Registration_Confirm $form */
$form = $this->getFormObject('CRM_Event_Form_Registration_Confirm');
$form->set('params', [[]]);
- $form->set('id', $event['id']);
$form->set('values', [
'event' => $event['values'][$event['id']],
'location' => [],
$mut->clearMessages();
}
+ /**
+ * Submit the confirm form.
+ *
+ * @param int $eventID
+ * @param array $params
+ * Array that would be stored in the form as params at this point.
+ * (ideally we will move to submitted rather than processed values
+ * in time).
+ */
+ protected function submitForm(int $eventID, array $params): void {
+ $_REQUEST['id'] = $eventID;
+ $form = $this->getFormObject('CRM_Event_Form_Registration_Confirm', []);
+ $form->set('params', [$params]);
+ $form->set('registerByID', $this->createLoggedInUser());
+ $form->buildForm();
+ $form->postProcess();
+ }
+
}