public function ContactRelationshipTestAdd::testSubmitWebform in Webform CiviCRM Integration 8.5
Test submitting Contact - Matching Rule
File
- tests/
src/ FunctionalJavascript/ ContactRelationshipTestAdd.php, line 43
Class
- ContactRelationshipTestAdd
- Tests submitting a Webform with CiviCRM: single contact + custom fields.
Namespace
Drupal\Tests\webform_civicrm\FunctionalJavascriptCode
public function testSubmitWebform() {
$this
->createContactSubtype();
$this
->createRelationshipType();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet(Url::fromRoute('entity.webform.civicrm', [
'webform' => $this->webform
->id(),
]));
// The label has a <div> in it which can cause weird failures here.
$this
->assertSession()
->waitForText('Enable CiviCRM Processing');
$this
->assertSession()
->waitForField('nid');
$this
->getSession()
->getPage()
->checkField('nid');
$this
->htmlOutput();
$this
->assertSession()
->waitForText('Number of Contacts');
$this
->assertSession()
->waitForField('number_of_contacts');
$this
->getSession()
->getPage()
->selectFieldOption('number_of_contacts', 2);
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput();
// Configuring Contact 1 - Student
$this
->getSession()
->getPage()
->selectFieldOption('civicrm_1_contact_1_contact_contact_sub_type[]', 'Student');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput();
// Configuring Contact 2 - School (Organization)
$this
->getSession()
->getPage()
->clickLink('2. Contact 2');
$this
->getSession()
->getPage()
->selectFieldOption('2_contact_type', 'Organization');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput();
$this
->getSession()
->getPage()
->checkField("civicrm_2_contact_1_contact_existing");
$this
->getSession()
->getPage()
->checkField("civicrm_2_contact_1_contact_organization_name");
$this
->assertSession()
->checkboxChecked("civicrm_2_contact_1_contact_organization_name");
$this
->getSession()
->getPage()
->selectFieldOption('contact_2_number_of_relationship', 'Yes');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput();
$this
->getSession()
->getPage()
->selectFieldOption('civicrm_2_contact_1_relationship_relationship_type_id[]', '- User Select -');
$this
->getSession()
->getPage()
->pressButton('Save Settings');
$this
->assertSession()
->pageTextContains('Saved CiviCRM settings');
$this
->assertPageNoErrorMessages();
// View and Submit!
$this
->drupalGet($this->webform
->toUrl('canonical'));
$this
->assertPageNoErrorMessages();
$this
->getSession()
->getPage()
->selectFieldOption('Relationship to Contact 1 Relationship Type(s)', 'School is');
// $this->createScreenshot($this->htmlOutputDirectory . '/relationship_user_select.png');
$this
->getSession()
->getPage()
->pressButton('Submit');
$this
->assertPageNoErrorMessages();
$this
->assertSession()
->pageTextContains('New submission added to CiviCRM Webform Test.');
}