public function ContributionPayLaterTest::testSubmitContribution in Webform CiviCRM Integration 8.5
File
- tests/
src/ FunctionalJavascript/ ContributionPayLaterTest.php, line 15
Class
- ContributionPayLaterTest
- Tests submitting a Webform with CiviCRM: Contribution with Pay later
Namespace
Drupal\Tests\webform_civicrm\FunctionalJavascriptCode
public function testSubmitContribution() {
$this
->createFinancialCustomGroup();
$this
->createFinancialCustomGroup('Donation');
$this
->createFinancialCustomGroup('Member Dues');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet(Url::fromRoute('entity.webform.civicrm', [
'webform' => $this->webform
->id(),
]));
$this
->enableCivicrmOnWebform();
//Enable Address fields.
$this
->getSession()
->getPage()
->selectFieldOption('contact_1_number_of_address', 1);
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->getSession()
->getPage()
->checkField('Country');
$this
->assertSession()
->checkboxChecked('Country');
$this
->configureContributionTab(TRUE, 'Pay Later');
$this
->getSession()
->getPage()
->checkField('Contribution Amount');
// Change financial type to Member Dues and confirm if its custom field is loaded.
$this
->getSession()
->getPage()
->selectFieldOption('Financial Type', 'Member Dues');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->verifyFTCustomSet('Member Dues');
$this
->getSession()
->getPage()
->selectFieldOption('Financial Type', 'Donation');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->verifyFTCustomSet('Donation');
$this
->getSession()
->getPage()
->checkField($this->_customFields['Donation']['label']);
$this
->saveCiviCRMSettings();
$this
->drupalGet($this->webform
->toUrl('edit-form'));
$this
->assertPageNoErrorMessages();
// Change widget of Amount element to checkbox.
$this
->changeTypeOfAmountElement('checkboxes');
$this
->submitWebform('checkboxes');
$this
->verifyResult();
// Change widget of Amount element to radios.
$this
->changeTypeOfAmountElement('radios');
$this
->submitWebform('radios');
$this
->verifyResult();
// Change widget of Amount element to radio + other.
$this
->changeTypeOfAmountElement('webform_radios_other');
$this
->submitWebform('webform_radios_other');
$this
->verifyResult();
}