function EventTest::testSubmitEventParticipant in Webform CiviCRM Integration 8.5
Event Participant submission.
File
- tests/
src/ FunctionalJavascript/ EventTest.php, line 146
Class
- EventTest
- Tests submitting a Webform with CiviCRM: Contact with Event.
Namespace
Drupal\Tests\webform_civicrm\FunctionalJavascriptCode
function testSubmitEventParticipant() {
$payment_processor = $this
->createPaymentProcessor();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet(Url::fromRoute('entity.webform.civicrm', [
'webform' => $this->webform
->id(),
]));
$this
->enableCivicrmOnWebform();
$this
->getSession()
->getPage()
->clickLink('Event Registration');
//Configure Event tab.
$this
->getSession()
->getPage()
->selectFieldOption('participant_reg_type', 'all');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput();
$this
->getSession()
->getPage()
->selectFieldOption('participant_1_number_of_participant', 1);
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput();
$this
->getSession()
->getPage()
->selectFieldOption('civicrm_1_participant_1_participant_event_id[]', 'Test Event');
$this
->getSession()
->getPage()
->checkField('Participant Fee');
//Configure Contribution tab.
$this
->configureContributionTab();
$this
->getSession()
->getPage()
->selectFieldOption('Payment Processor', $payment_processor['id']);
$this
->enableBillingSection();
$this
->saveCiviCRMSettings();
$this
->drupalGet($this->webform
->toUrl('canonical'));
$this
->assertPageNoErrorMessages();
$edit = [
'First Name' => 'Frederick',
'Last Name' => 'Pabst',
'Email' => 'fred@example.com',
'Participant Fee' => 20,
];
$this
->postSubmission($this->webform, $edit, 'Next >');
$this
->assertSession()
->elementExists('css', '#wf-crm-billing-items');
$this
->htmlOutput();
$this
->assertSession()
->elementTextContains('css', '#wf-crm-billing-total', '20.00');
// Wait for the credit card form to load in.
$this
->assertSession()
->waitForField('credit_card_number');
$this
->getSession()
->getPage()
->fillField('Card Number', '4222222222222220');
$this
->getSession()
->getPage()
->fillField('Security Code', '123');
$this
->getSession()
->getPage()
->selectFieldOption('credit_card_exp_date[M]', '11');
$this_year = date('Y');
$this
->getSession()
->getPage()
->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1);
$billingValues = [
'first_name' => 'Frederick',
'last_name' => 'Pabst',
'street_address' => '123 Milwaukee Ave',
'city' => 'Milwaukee',
'country' => '1228',
'state_province' => '1048',
'postal_code' => '53177',
];
$this
->fillBillingFields($billingValues);
$this
->getSession()
->getPage()
->pressButton('Submit');
$this
->htmlOutput();
$this
->assertSession()
->pageTextContains('New submission added to CiviCRM Webform Test.');
//Assert if recur is attached to the created membership.
$utils = \Drupal::service('webform_civicrm.utils');
$api_result = $utils
->wf_civicrm_api('participant', 'get', [
'sequential' => 1,
]);
$this
->assertEquals(0, $api_result['is_error']);
$this
->assertEquals(1, $api_result['count']);
$this
->assertEquals($this->_event['id'], $api_result['values'][0]['event_id']);
}