You are here

public function ExistingContactElementTest::testSubmitWebform in Webform CiviCRM Integration 8.5

File

tests/src/FunctionalJavascript/ExistingContactElementTest.php, line 30

Class

ExistingContactElementTest
Tests submitting a Webform with CiviCRM: existing contact element.

Namespace

Drupal\Tests\webform_civicrm\FunctionalJavascript

Code

public function testSubmitWebform() {
  $this
    ->addcontactinfo();
  $this
    ->drupalLogin($this->rootUser);
  $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
    ->enableCivicrmOnWebform();
  $this
    ->saveCiviCRMSettings();
  $this
    ->drupalGet($this->webform
    ->toUrl('canonical'));
  $this
    ->assertPageNoErrorMessages();
  $this
    ->assertSession()
    ->waitForField('First Name');

  // The Default Existing Contact Element behaviour is: load logged in User
  // The test here is to check if the fields on the form populate with Contact details belonging to the logged in User:
  $this
    ->assertSession()
    ->fieldValueEquals('First Name', 'Maarten');
  $this
    ->assertSession()
    ->fieldValueEquals('Last Name', 'van der Weijden');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Submit');
  $this
    ->assertPageNoErrorMessages();
  $this
    ->assertSession()
    ->pageTextContains('New submission added to CiviCRM Webform Test.');
}