You are here

private function StripeTest::fillStripeCardWidget in Webform CiviCRM Integration 8.5

Fill values on the stripe card element.

1 call to StripeTest::fillStripeCardWidget()
StripeTest::testSubmitContribution in tests/src/FunctionalJavascript/StripeTest.php
Test webform submission using stripe processor. Verifies the payment with 1 contribution and 2 line item amounts.

File

tests/src/FunctionalJavascript/StripeTest.php, line 109

Class

StripeTest
Tests submitting a Webform with CiviCRM: Contribution with Line Items

Namespace

Drupal\Tests\webform_civicrm\FunctionalJavascript

Code

private function fillStripeCardWidget() {
  $expYear = date('y') + 1;

  // Wait for the credit card form to load in.
  $stripeCardElement = $this
    ->assertSession()
    ->waitForElementVisible('xpath', '//div[contains(@class, "StripeElement")]/div/iframe');
  $this
    ->assertNotEmpty($stripeCardElement);
  $this
    ->getSession()
    ->switchToIFrame($stripeCardElement
    ->getAttribute('name'));
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->waitForElementVisible('css', 'input[name="cardnumber"]');
  $this
    ->getSession()
    ->getPage()
    ->fillField('cardnumber', '4111 1111 1111 1111');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->getSession()
    ->getPage()
    ->fillField('exp-date', '11 / ' . $expYear);
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->getSession()
    ->getPage()
    ->fillField('cvc', '123');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->getSession()
    ->getPage()
    ->fillField('postal', '12345');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->getSession()
    ->switchToIFrame();
}